• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Record类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Record的典型用法代码示例。如果您正苦于以下问题:Python Record类的具体用法?Python Record怎么用?Python Record使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Record类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: new_record

def new_record(id):
    user = User.query.get_or_404(id)
    record = Record(user=user)
    record.import_data(request.json)
    db.session.add(record)
    db.session.commit()
    return jsonify({}), 201, {'Location': record.get_url()}
开发者ID:tsh,项目名称:workload,代码行数:7,代码来源:api.py


示例2: save

    def save(self,record=None):
        if record:
            links = []
            if self.validated_data['gwc']:
                links.append(
                    json.loads(Record.generate_ows_link(self.validated_data['gwc_endpoint'],'WMS',None,record))
                )
            if self.validated_data['wms']:
                links.append(
                    json.loads(Record.generate_ows_link(self.validated_data['wms_endpoint'],'WMS',self.validated_data['wms_version'],record))
                )
            if self.validated_data['wfs']:
                links.append(
                    json.loads(Record.generate_ows_link(self.validated_data['wfs_endpoint'],'WFS',self.validated_data['wfs_version'],record))
                )
                
            if record.service_type == "WMS":
                record.service_type_version = self.validated_data['wms_version']
            elif record.service_type == "WFS":
                record.service_type_version = self.validated_data['wfs_version']
            else:
                record.service_type_version = ""

            style_resources = record.style_resources
            resources = links + style_resources

            Record.update_links(resources,record)
开发者ID:dpawasi,项目名称:oim-cms,代码行数:27,代码来源:api.py


示例3: gong

def gong(request):
    user = "@%s" % request.POST.get("user_name", "somebody")
    reason = request.POST.get("text", "Gonged stuff!")

    slack_message('slack/gonged.slack', {
        'user': user,
        'reason': reason
    })

    attachments = [
        {
            'author_name': user,
            'title': reason,
            'image_url': 'https://curriculum.code.org/images/gong.gif',
            'color': '#00adbc'
        }
    ]
    payload = {
        "response_type": "in_channel",
        "attachments": attachments,
    }

    record = Record(user=user, reason=reason)
    record.save()

    return Response(payload, content_type='application/json')
开发者ID:mrjoshida,项目名称:curriculumbuilder,代码行数:26,代码来源:views.py


示例4: rest

def rest(request):
	admins_email = ['[email protected]']
	content_to_sender = u"Dear %s,\n\nWe have received your application.Please do NOT reply this email directly.\n\nThanks,\nTech Team"
	content_to_admin = u"Received an application from %s %s at %s"
	receive_time_str = strftime("%H:%M:%S %Y-%m-%d", localtime())
	if request.META.has_key('CONTENT_TYPE'):
		info = request.META['CONTENT_TYPE'] 
		if info == 'application/json' and request.method == 'POST':
			data = json.loads(request.body) 
			form = RecordForm(data)

			if form.is_valid():
				r = Record(email = form.cleaned_data['email'],
							first_name = form.cleaned_data['first_name'],
							last_name = form.cleaned_data['last_name'],
							contact_number = form.cleaned_data['contact_number'],
							title = form.cleaned_data['title'],
							content = form.cleaned_data['content'],
							link = form.cleaned_data['link'])
				r.save()

				send_mail(u'Thanks for your application',
							content_to_sender % data['last_name'],
							'[email protected]',
							[data['email']])
				send_mail(u'Application Received from %s' % data['email'],
							content_to_admin % (data['last_name'],data['first_name'],receive_time_str),
							'[email protected]',
							admins_email)
				return HttpResponse('save successful')
		return HttpResponse('data invalid')	
	else:
		return HttpResponse('Please verify Header info')
开发者ID:fl0wjacky,项目名称:rest_test,代码行数:33,代码来源:views.py


示例5: add_record

def add_record(release):
    from models import Record, Artist, Track
    release_discogs_id = release.id
    try:
        # Check if we already have this album
        existing = Record.objects.get(discogs_id=release_discogs_id)
        return existing
    except Record.DoesNotExist:
        # Process record
        record_title = release.title
        if (len(record_title.split('- '))>1):
            record_title = record_title.split('- ')[1]
        record = Record(discogs_id = release_discogs_id, title = record_title, year = release.year, thumb = release.thumb, notes = release.notes)
        record.save()

        # Process artists
        for release_artist in release.artists:
            artist = Artist(discogs_id=release_artist.id, name=release_artist.name)
            artist.save()
            record.artists.add(artist)

        # Process tracklist
        for release_track in release.tracklist:
            track = Track()
            track.position = release_track.position
            track.title = release_track.title
            track.duration = release_track.duration
            track.save()
            record.tracklist.add(track)

        record.save()
        return record
开发者ID:chriswait,项目名称:Record-Collection,代码行数:32,代码来源:discogs.py


示例6: save

    def save(self, record=None):
        if record:
            links = []
            if self.validated_data['gwc']:
                gwc_endpoints = [endpoint.strip() for endpoint in self.validated_data['gwc_endpoint'].split("^") if endpoint.strip()]
                for endpoint in gwc_endpoints:
                    links.append(
                        record.generate_ows_link(endpoint, 'GWC', self.validated_data['wms_version'])
                    )
            elif self.validated_data['wms']:
                links.append(
                    record.generate_ows_link(self.validated_data['wms_endpoint'], 'WMS', self.validated_data['wms_version'])
                )
            if self.validated_data['wfs']:
                links.append(
                    record.generate_ows_link(self.validated_data['wfs_endpoint'], 'WFS', self.validated_data['wfs_version'])
                )
            if record.service_type == "WMS":
                record.service_type_version = self.validated_data['wms_version']
            elif record.service_type == "WFS":
                record.service_type_version = self.validated_data['wfs_version']
            else:
                record.service_type_version = ""

            style_links = record.style_links
            resources = links + style_links

            Record.update_links(resources, record)
开发者ID:rockychen-dpaw,项目名称:oim-cms,代码行数:28,代码来源:api.py


示例7: delete

def delete(instance, obj_id):
    obj = Record().give_child(instance)
    obj = obj.get_by_id_or_new(obj_id)
    obj.delete()
    if not request.is_xhr:
        return redirect('index/'+repr(obj))
    else:
        return "it ok"
开发者ID:HardBite,项目名称:flibr,代码行数:8,代码来源:views.py


示例8: get_user_rankings

 def get_user_rankings(self, request):
     """Get user rankings"""
     if isinstance(request.number_of_results, int):
         _number_of_results = request.number_of_results
         records = Record.query().order(Record.wins).fetch(limit=_number_of_results)
         return RecordForms(items=[record.to_form() for record in records])
     else:
         records = Record.query().order(Record.wins)
         return RecordForms(items=[record.to_form() for record in records])
开发者ID:sensi501,项目名称:GAE-Concentration,代码行数:9,代码来源:api.py


示例9: record_user

def record_user(request,user):
	user = User.objects.get(id=user)
	summary = Record.summary_by_user(user)
	records = Record.list_by_user(user)

	context = {'records':records,
		'summary':summary,}
	
	return render_to_response('user.html', context,context_instance=RequestContext(request))
开发者ID:bingwen,项目名称:drive-record,代码行数:9,代码来源:views.py


示例10: testExpressionParsing

    def testExpressionParsing(self):
        from models import Record
        r = Record()
        x = 5
        y = -2
        z = 3.5
        r.setColumnValue("x", x)
        r.setColumnValue("y", y)
        r.setColumnValue("z", z)
        volley = [
            ["1 + 1", (1 + 1) ],
            ["1 + 1 + 5", (1 + 1 + 5) ],
            ["2 * 8 + 3", (2*8) + 3 ],
            ["4 + 5 * 2", 4 + (5*2)],
            ["2^3", (pow(2,3)) ],
            ["(8/2)*3 + 9", ((8/2)*3 + 9) ],
            ["[x]^2", (pow(x,2))],
            ["SQRT([x]^2 + [y]^2)", ( math.sqrt(pow(x,2)+pow(y,2)) )],
            ["5 > 2", True],
            ["5 > 6", False],
            ["(3*5) < 20", True],
            ["[x] > 100", False],
            ["(3*5) < 20 AND [x] > 100", False],
            ["(3*5) < 20 AND [x] > 0 AND [x] > 1", True],
            ["1==1 OR 1==3 AND 2==0", True],
            ["(1==1 OR 1==3) AND 2==2", True],
            ["(1==2 AND 1==3) OR 2==2", True],
            ["(1==1 OR 1==1) AND 1==0", False],
            ["1==1 OR 1==1 AND 1==0", True], # And first
            ["1==1 OR (1==1 AND 1==0)", True],
            ["1 == 2 OR [x] > 100 OR [x] > 1", True],
            ["1==2 OR 1==1 OR 1==4 OR 1==5", True],
            ["SQRT([x]^2 + [y]^2)", ( math.sqrt(pow(x,2)+pow(y,2)) )],
            ["SQRT([x]^2 + [y]^2 + 8^2)", ( math.sqrt(pow(x,2)+pow(y,2)+pow(8,2))) ],
            ["SQRT([x]^2 + [y]^2 + [z]^2)", ( math.sqrt(pow(x,2)+pow(y,2)+pow(z,2))) ]
        ]

        for v in volley:
            expr = v[0]
            target = v[1]
            tick = datetime.now()
            ep = ExpressionParser(expr, verbose=True)
            result = ep.run(r)
            tock = datetime.now()
            diff = tock - tick
            ms = diff.microseconds/1000
            logmessage = "%s took %d ms" % (expr, ms)
            if ms > 100:
                logmessage += " <<<<<<<<<<<<<<<<<<<<<<<<<<< SLOW OP!"
            print logmessage
            self.assertEqual(result, target)
开发者ID:ArnoldOchieng,项目名称:echo-sense,代码行数:51,代码来源:testing_util.py


示例11: instantiate_and_form

def instantiate_and_form(request, instance, obj_id=None):
    """
    Abstracts common operations from actions add/<instance>, edit/<instance>.
    Instantiates blank model object obj by it's string name (i. e.
    instance=book will produce obj=Book()). Instantiates corresponding
    WTForm model_form object form. If obj_id provided, tries to populate
    obj with database data.
    Populates form with request.from data (if any). Than tries to modify
    obj with data in form. Returns ready to use obj, form to caller.
    """
    obj = Record().give_child(instance)
    form = obj.give_form()
    obj = obj.get_by_id_or_new(obj_id)
    form = form(request.form, obj=obj)
    obj.populate_with(form)
    return obj, form
开发者ID:HardBite,项目名称:flibr,代码行数:16,代码来源:views.py


示例12: get

    def get(self):
        """Handles GET."""

        height = self.request.GET.get('height', 600)
        width = self.request.GET.get('width', 1000)
        num = int(self.request.GET.get('num', 100))
        if num > 1000:
            num = 1000

        records = Record.all().order('-num_iter').order('-date').fetch(num)

        values = [r.estimated_pi for r in records]

        num_rows = len(values)

        rows = []

        for i in range(num_rows):
            rows.append("%i, 0, %i" % (i, i+1))
            rows.append("%i, 1, %f" % (i, values[i]))

        if values:
            pi = sum(values)/num_rows
        else:
            pi = 'unknown'

        self.response.out.write(template.render('chart.html', locals()))
开发者ID:rodaebel,项目名称:montecarlo,代码行数:27,代码来源:app.py


示例13: render_review_page

def render_review_page():
  """
  Render the review page.
  """
  title = 'Review'
  pending = Record.get_all_pending_records()
  return render_template('review.html', page_title=title, pending=pending)
开发者ID:jzhang621,项目名称:merit_app,代码行数:7,代码来源:__init__.py


示例14: update

def update(POST):
    player_one = Player.objects.get(pk=int(POST['player_one']))
    player_one_score = int(POST['player_one_score'])
    player_two = Player.objects.get(pk=int(POST['player_two']))
    player_two_score = int(POST['player_two_score'])

    record = Record(date=datetime.datetime.now(), player_one_id=player_one.id, player_one_score=player_one_score, player_two_id=player_two.id, player_two_score=player_two_score)
    record.save()

    if player_one.ELO > player_two.ELO:
        expected_one = get_Expected(player_one.ELO, player_two.ELO)
    else:
        expected_one = 1 - get_Expected(player_two.ELO, player_one.ELO)

    update_player(player_one, player_one_score, player_two, player_two_score, expected_one)
    update_player(player_two, player_two_score, player_one, player_one_score, 1-expected_one)
开发者ID:SteveXian,项目名称:ELO-Ranking-Server,代码行数:16,代码来源:elo.py


示例15: record_user_road

def record_user_road(request,user,road):
	user = User.objects.get(id=user)
	records = Record.objects.filter(user=user,road=road)
	summary = Record.summary_by_user_road(user,road)
	context = {'user':user,
		'records':records,
		'summary':summary,}
	return render_to_response('record-user-road.html', context,context_instance=RequestContext(request))
开发者ID:bingwen,项目名称:drive-record,代码行数:8,代码来源:views.py


示例16: collection_dump

def collection_dump(user, identifier, stream=None, prefix=None):

    # export collection
    collection = filter_by_access(user, Collection).get(id=identifier)

    # export collection items and records
    collectionitems = list(
        CollectionItem.objects
        .select_related('record', 'collection')
        .filter(collection__id=identifier)
    )
    ids = [collectionitem.record_id for collectionitem in collectionitems]
    records = list(Record.filter_by_access(user, *ids).filter(owner=None))
    ids = [record.id for record in records]
    collectionitems = [collectionitem for collectionitem in collectionitems
                       if collectionitem.record_id in ids]

    # export all fieldvalues
    fieldvalues = FieldValue.objects.select_related('record', 'field').filter(
        record__id__in=ids)

    used_fields = set(fieldvalue.field_id for fieldvalue in fieldvalues)

    # export all used fields
    fields = list(Field.objects.filter(id__in=used_fields).distinct())

    # export equivalent fields
    more = True
    while more:
        eq_ids = set(
            id
            for field in fields
            for id in field.equivalent.values_list('id', flat=True)
            if id not in used_fields
        )
        more = len(eq_ids) > 0
        if more:
            eq_fields = Field.objects.filter(id__in=eq_ids)
            fields.extend(eq_fields)
            used_fields = used_fields.union(eq_ids)

    # export all used standards
    standards = MetadataStandard.objects.filter(id__in=set(
        field.standard_id for field in fields if field.standard_id
    ))

    objects = [collection]
    objects.extend(standards)
    objects.extend(fields)
    objects.extend(collectionitem.record for collectionitem in collectionitems)
    objects.extend(collectionitems)
    objects.extend(fieldvalues)

    serializer = RenamingSerializer(prefix)
    kwargs = dict()
    if stream:
        kwargs['stream'] = stream
    return serializer.serialize(objects, use_natural_keys=True, **kwargs)
开发者ID:hanleybrand,项目名称:rooibos,代码行数:58,代码来源:functions.py


示例17: home

def home(request):
	records = Record.list()
	total_times = int(0)
	for x in records:
		total_times += x['times']
	summary = {'user_num':User.objects.all().count,
	'total_times':total_times}
	context = {'records':records,'summary':summary,}
	return render_to_response('index_list.html', context,context_instance=RequestContext(request))
开发者ID:bingwen,项目名称:drive-record,代码行数:9,代码来源:views.py


示例18: time_step2

def time_step2(request):
    _ip = request.POST["IP"]
    _time_step2 = request.POST["Time_step2"]

    try:
        record = Record.objects(ip=_ip)
    except DoesNotExist:
        return HttpResponse(status=400)
    record.time_step2 = str(_time_step2)
    record.save()
开发者ID:noobxinyu,项目名称:lionet_fyp,代码行数:10,代码来源:views.py


示例19: create_user

    def create_user(self, request):
        """Create a User"""
        # Checks if user provided user name exists in database
        if User.query(User.name == request.user_name).get():
            raise endpoints.ConflictException(\
                    'A User with that name already exists!')

        # Creates new player record and user 
        # based on user inputed name and email
        user = User(name=request.user_name, 
                    email=request.email)
        user.put()

        record = Record(user=user.key,
                        wins=0,
                        loses=0)
        record.put()

        return StringMessage(message='User {} created!'.format(request.user_name))
开发者ID:sensi501,项目名称:GAE-Concentration,代码行数:19,代码来源:api.py


示例20: record_preview

def record_preview(request, id):
    record = Record.get_or_404(id, request.user)
    return render_to_response(
        'data_previewrecord.html',
        {
            'record': record,
            'none': None,
        },
        context_instance=RequestContext(request)
    )
开发者ID:hanleybrand,项目名称:rooibos,代码行数:10,代码来源:views.py



注:本文中的models.Record类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Report类代码示例发布时间:2022-05-27
下一篇:
Python models.Question类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap