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

Python traversal.find_root函数代码示例

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

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



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

示例1: add_deadline

def add_deadline(context, request):
    logged_in = authenticated_userid(request)
    main = get_renderer('../templates/master.pt').implementation()
    schema = DeadlineSchema()
    deadlineform = Form(schema, buttons=('submit',),use_ajax=True)
    if 'dateDue' in request.params:
        try:
            controls = request.POST.items()
            captured = deadlineform.validate(controls)
        except deform.ValidationFailure, e:
            deadlineform = e.render()
            return {'red':'',
                    'main':main, 
                    'form':deadlineform, 
                    'content':'',
                    'logged_in':logged_in,
                    'name':'Add Deadline'}
        dateDue = calendarstuff.datetime_from_str(request.params['dateDue'])
        hours = request.params['hours']
        sponsored = request.params['sponsored']
        appliedClass = request.params['appliedClass']
        context.count += 1
        deadline = Deadline(dateDue,hours,sponsored,appliedClass,context.count)
        deadline.__parent__ = context
        context[str(context.count)] = deadline
        find_root(context)['activityLogs'].deadline_creation(find_root(request.context)["users"][logged_in],deadline,request.application_url)
        return {'red':'deadlines/',
                'main':main,
                'form':'',
                'content':"Added a Deadline",
                'logged_in':logged_in,
                'name':'Redirecting...'}
开发者ID:ellimistd,项目名称:yhsnhs,代码行数:32,代码来源:deadlineviews.py


示例2: add_sponsored_event

def add_sponsored_event(context,request):
    logged_in = authenticated_userid(request)
    user = find_root(request.context)['users'][logged_in]
    main = get_renderer('../templates/master.pt').implementation()
    projectList = find_root(context)["settings"].projects
    projectTupleList = []
    for project in projectList:
        projectTupleList.append((project,project))
    projectTupleTuple=tuple(projectTupleList)   #sorry about this.  It was more fun than a ListList
    class SponsoredEventSchema(colander.MappingSchema):
        completionDate = colander.SchemaNode(colander.Date(),title="Completion Date (YYYY-MM-DD): ")
        hours = colander.SchemaNode(colander.Float(), title="Number of Hours: ")
        description = colander.SchemaNode(
                colander.String(),
                validator=colander.OneOf([x[0] for x in projectTupleTuple]),
                widget=deform.widget.RadioChoiceWidget(values=projectTupleTuple),
                title='Project',
                description='Select a Project')
        taskDescription = colander.SchemaNode(
                    colander.String(), title="Description: ",
                    widget=deform.widget.TextAreaWidget(rows=5, cols=40),
                    description='Enter some text')
        contact = colander.SchemaNode(colander.String(),title="Contact Name: ")
        contactInfo = colander.SchemaNode(colander.String(),title="Contact Info: ")
    schema=SponsoredEventSchema()
    eventform = Form(schema, buttons=('submit',))
    if 'taskDescription' in request.params:
        try:
            controls = request.POST.items()
            captured = eventform.validate(controls)
        except deform.ValidationFailure, e:
            eventform = e.render()
            return {'red':'',
                    'main':main, 
                    'form':eventform, 
                    'content':'',
                    'logged_in':logged_in,
                    'name':'Add Sponsored Event',
		    'TutText': getTutText(user, view='')}
        completionDate = calendarstuff.datetime_from_str(request.params['completionDate'])
        hours = request.params['hours']
        description = request.params['deformField3']
        taskDescription = request.params['taskDescription']
        contact = request.params['contact']
        contactInfo = request.params['contactInfo']
        context.eventcount += 1
        user = context.user
        event = Event("Sponsored","N/A",completionDate,hours,description,taskDescription,contact,contactInfo,user,context.eventcount)
        event.__parent__ = context
        context[str(context.eventcount)] = event
        activitylog = find_root(context)['activityLogs']
        activitylog.event_creation(find_root(request.context)["users"][logged_in],event,request.application_url)
        return {'red':'serviceLogs/'+context.user.username,
                'main':main,
                'form':'',
                'content':"Added sponsored event for "+description,
                'logged_in':logged_in,
                'name':'Redirecting...',
		'TutText': getTutText(user, view='')}
开发者ID:C453,项目名称:yhs_nhs,代码行数:59,代码来源:eventviews.py


示例3: add_user

def add_user(context, request):
    logged_in = authenticated_userid(request)
    main = get_renderer('../templates/master.pt').implementation()
    schema = UserSchema()
    userform = Form(schema, buttons=('submit',),use_ajax=True)
    if 'username' in request.params:
        try:
            controls = request.POST.items()
            captured = userform.validate(controls)
        except deform.ValidationFailure, e:
            userform = e.render()
            return {'red':'',
                     'main':main,
                     'form':userform,
                     'content':'',
                     'logged_in':logged_in,
                     'name':'Add User',
		     'TutText': getTutText(context, view='')}
        username = request.params['username']
        if username in context:
            return {'red':'',
                     'logged_in':logged_in,
                     'main':main,
                     'form':'',
                     'content':'Sorry, the username '+username+' already exists in this system.  Please try again, or contact an administrator.',
                     'name':'Users',
		     'TutText': getTutText(context, view='')}
        password = hashlib.sha1(request.params["confirm"].encode('UTF-8')).digest()
        studentId = request.params['studentId']
        firstName = request.params['firstName']
        lastName = request.params['lastName']
        email = request.params['email']
        phone = request.params['phone']
        gradYear = request.params['gradYear']
        inductionYear = request.params['inductionYear']
        user = User(username,
                    password,
                    studentId,
                    firstName = firstName,
                    lastName = lastName,
                    email = email,
                    phone = phone,
                    gradYear = gradYear,
                    inductionYear = inductionYear)
        user.__parent__ = context
        context[username] = user
        serviceLog = ServiceLog(user)
        serviceLog.__parent__ = find_root(user)['serviceLogs']
        find_root(user)['serviceLogs'][username]=serviceLog
        user.serviceLog = ServiceLog
        find_root(context)['activityLogs'].user_creation(find_root(request.context)["users"][logged_in],user,request.application_url)
        return {'red':'users/',
                 'main':main,
                 'form':'',
                 'content':'The user '+firstName+' '+lastName+' was added to the system, with a username of '+username,
                 'logged_in':logged_in,
                 'name':'Redirecting...',
		 'TutText': getTutText(context, view='')}
开发者ID:C453,项目名称:yhs_nhs,代码行数:58,代码来源:userviews.py


示例4: csvimport

def csvimport(context,request):
    logged_in = authenticated_userid(request)
    main = get_renderer('../templates/master.pt').implementation()
    schema = TextFieldSchema()
    importform = Form(schema, buttons=('submit',))
    if 'submit' in request.params:
        inputstring = str(request.params["text"])
        inputstring = inputstring.replace("\r","")
        inputstring = inputstring.replace(", ",",")
        lines = inputstring.split("\n")
        inputlist = []
        for line in lines:
            if not line == "":
                ul = line.split(",")
                user = User(
                            ul[2], #username
                            hashlib.sha1(ul[8].encode('UTF-8')).digest(), #password, encoded
                            ul[3], #studentID
                            firstName = ul[1],
                            lastName = ul[0],
                            email = ul[4],
                            phone = ul[5],
                            gradYear = ul[6],
                            inductionYear = ul[7]
                            )
                username = ul[2]
                if username in context:
                    return {'red':'',
                             'logged_in':logged_in,
                             'main':main,
                             'form':exportform.render(),
                             'content':"ERROR: the username "+username+" already exists in this system.  Please reassess your input data.",
                             'name':'Import From CSV',
			     'TutText': getTutText(context, view='')}
                user.__parent__ = context
                context[username] = user
                serviceLog = ServiceLog(user)
                serviceLog.__parent__ = find_root(user)['serviceLogs']
                find_root(user)['serviceLogs'][username]=serviceLog
                user.serviceLog = ServiceLog
                find_root(context)['activityLogs'].user_creation(find_root(request.context)["users"][logged_in],user,request.application_url)
        return {'red':'users/',
                 'main':main,
                 'logged_in':logged_in,
                 'form':'',
                 'content':'Imported Users from CSV',
                 'name':'Redirecting...',
		 'TutText': getTutText(context, view='')}
    return {'red':'',
             'main':main,
             'logged_in':logged_in,
             'form':importform.render(),
             'content':'',
             'name':'Import From CSV',
	     'TutText': getTutText(context, view='')}
开发者ID:C453,项目名称:yhs_nhs,代码行数:55,代码来源:userviews.py


示例5: view_servicelog

def view_servicelog(context,request):
    logged_in = authenticated_userid(request)
    currentuser = find_root(request.context)["users"][logged_in]
    main = get_renderer('../templates/master.pt').implementation()
    app = find_root(request.context)
    if currentuser.isOfficer:
        if "action" in request.params:
            for ID in request.params.keys():
                if not ID in ['action','comment','note']:
                    event = context[ID]
                    if request.params["action"] == "delete":
                        if event.verified == "Verified":
                            event.user.hours -= float(event.hours)
                            if event.eventType == "Sponsored":
                                event.user.sponsored -= float(event.hours)
                        app['activityLogs'].event_deactivation(currentuser,event,request.application_url)
                        del event.__parent__[str(event.ID)]
                    elif request.params["action"] == "verify":
                        if not event.verified == "Verified":
                            event.user.hours += float(event.hours)
                            if event.eventType == "Sponsored":
                                event.user.sponsored += float(event.hours)
                        event.verified = "Verified"
                        app['activityLogs'].event_verification(currentuser,event,request.application_url)
                    elif request.params["action"] == "flag":
                        if event.verified == "Verified":
                            event.user.hours -= float(event.hours)
                            if event.eventType == "Sponsored":
                                event.user.sponsored -= float(event.hours)
                        event.verified = "Flagged"
                        find_root(context)['activityLogs'].event_flagging(currentuser,event,request.application_url)
                    elif request.params["action"] == "unverify":
                        if event.verified == "Verified":
                            event.user.hours -= float(event.hours)
                            if event.eventType == "Sponsored":
                                event.user.sponsored -= float(event.hours)
                        event.verified = "Unverified"
                        find_root(context)['activityLogs'].event_unverification(currentuser,event,request.application_url)
                    if request.params["comment"]:
                        if event.comment:
                            event.comment += " "+request.params['comment']
                        else:
                            event.comment = request.params['comment']
    permission=True
    red=''
    if not logged_in == context.user.username:
        if not find_root(context)['users'][logged_in].isAdvisor and not find_root(context)['users'][logged_in].isOfficer:
            permission=False
            red = 'serviceLogs'
    userclass = calendarstuff.class_from_year(context.user.gradYear)
    deadlines = find_root(context)["deadlines"]
    now = datetime.now()
    return {'red':red,
             'main':main,
             'content':context,
             'logged_in':logged_in,
             'name':'Service Logs',
             'isallowed':permission,
             'deadlines':deadlines}
开发者ID:ellimistd,项目名称:yhsnhs,代码行数:59,代码来源:servicelogviews.py


示例6: add_independent_event

def add_independent_event(context, request):
    logged_in = authenticated_userid(request)
    main = get_renderer("../templates/master.pt").implementation()
    schema = IndependentEventSchema()
    eventform = Form(schema, buttons=("submit",))
    if "description" in request.params:
        try:
            controls = request.POST.items()
            captured = eventform.validate(controls)
        except deform.ValidationFailure, e:
            eventform = e.render()
            return {
                "red": "",
                "main": main,
                "form": eventform,
                "content": "",
                "logged_in": logged_in,
                "name": "Add Independent Event",
            }
        completionDate = calendarstuff.datetime_from_str(request.params["completionDate"])
        hours = request.params["hours"]
        description = request.params["description"]
        taskDescription = request.params["taskDescription"]
        contact = request.params["contact"]
        contactInfo = request.params["contactInfo"]
        affects = request.params["affects"]
        context.eventcount += 1
        user = context.user
        event = Event(
            "Independent",
            completionDate,
            hours,
            description,
            taskDescription,
            contact,
            contactInfo,
            user,
            context.eventcount,
            affects=affects,
        )
        event.__parent__ = context
        context[str(context.eventcount)] = event
        activitylog = find_root(context)["activityLogs"]
        activitylog.event_creation(find_root(request.context)["users"][logged_in], event, request.application_url)
        return {
            "red": "serviceLogs/" + context.user.username,
            "main": main,
            "form": "",
            "content": "Added independent event for " + description,
            "logged_in": logged_in,
            "name": "Redirecting...",
        }
开发者ID:ellimistd,项目名称:yhsnhs,代码行数:52,代码来源:eventviews.py


示例7: add_entry

def add_entry(context, request):
    if 'submit' in request.params:
        session = DBSession()
        title = request.params['title']
        text = request.params['text']
        entry = Entry(title, text)
        session.add(entry)
        return HTTPFound(location=request.resource_url(find_root(context)))
    add_url = request.resource_url(find_root(context), 'add')
    return {'mode': 'Add',
            'title':'',
            'text':'',
            'add_url':add_url}
开发者ID:inoshiro,项目名称:junk_code,代码行数:13,代码来源:views.py


示例8: hoursimport

def hoursimport(context,request):
    logged_in = authenticated_userid(request)
    main = get_renderer('../templates/master.pt').implementation()
    schema = TextFieldSchema()
    importform = Form(schema, buttons=('submit',))
    if 'submit' in request.params:
        inputstring = str(request.params["text"])
        inputstring = inputstring.replace("\r","")
        inputstring = inputstring.replace(", ",",")
        lines = inputstring.split("\n")
        inputlist = []
        for line in lines:
            if not line == "":
                rl = line.split(",")
                for value in rl[1:]:
                    try:
                        value = float(value)
                    except ValueError:
                        return {'red':'',
                                 'logged_in':logged_in,
                                 'main':main,
                                 'form':exportform.render(),
                                 'content':"ERROR: Input data was not a number, and could not be processed.  Please reassess your input data.",
                                 'name':'Import Hours From CSV',
				 'TutText': getTutText(context, view='')}
                username = rl[0]
                if not username in context:
                    return {'red':'',
                             'logged_in':logged_in,
                             'main':main,
                             'form':exportform.render(),
                             'content':"ERROR: the username "+username+" does not exist in this system.  Please reassess your input data.",
                             'name':'Import Hours From CSV',
			     'TutText': getTutText(context, view='')}
                context[username].hours = rl[1]
                context[username].sponsored = rl[2]
                find_root(context)['activityLogs'].user_edit(context[logged_in],context[username],request.application_url)
        return {'red':'users/',
                 'main':main,
                 'logged_in':logged_in,
                 'form':'',
                 'content':'Imported Hours from CSV',
                 'name':'Redirecting...',
		 'TutText': getTutText(context, view='')}
    return {'red':'',
             'main':main,
             'logged_in':logged_in,
             'form':importform.render(),
             'content':'',
             'name':'Import Hours From CSV',
	     'TutText': getTutText(context, view='')}
开发者ID:C453,项目名称:yhs_nhs,代码行数:51,代码来源:userviews.py


示例9: requirementsimport

def requirementsimport(context,request):
    logged_in = authenticated_userid(request)
    main = get_renderer('../templates/master.pt').implementation()
    schema = TextFieldSchema()
    importform = Form(schema, buttons=('submit',))
    if 'submit' in request.params:
        inputstring = str(request.params["text"])
        inputstring = inputstring.replace("\r","")
        inputstring = inputstring.replace(", ",",")
        lines = inputstring.split("\n")
        inputlist = []
        for line in lines:
            if not line == "":
                rl = line.split(",")
                for value in rl[1:]:
                    if value in ['Yes', 'YES', 'yes', 'Y', 'y']:
                        value = True
                    elif value in ['No', 'NO', 'no', 'N', 'n']:
                        value = False
                    if type(value) != type(True):
                        return {'red':'',
                                 'logged_in':logged_in,
                                 'main':main,
                                 'form':exportform.render(),
                                 'content':"ERROR: Input data was not either 'yes' or 'no', and could not be processed.  Please reassess your input data.",
                                 'name':'Import Requirements From CSV',
				 'TutText': getTutText(context, view='')}
                username = rl[0]
                if not username in context:
                    return {'red':'','logged_in':logged_in,'main':main,'form':exportform.render(), 'content':"ERROR: the username "+username+" does not exist in this system.  Please reassess your input data.",'name':'Import Requirements From CSV'}
                context[username].dues = rl[1]
                context[username].gpa = rl[2]
                context[username].firstMeeting = rl[3]
                context[username].secondMeeting = rl[4]
                context[username].thirdMeeting = rl[5]
                find_root(context)['activityLogs'].user_edit(context[logged_in],context[username],request.application_url)
        return {'red':'users/',
                 'main':main,
                 'logged_in':logged_in,
                 'form':'',
                 'content':'Imported Information from CSV',
                 'name':'Redirecting...',
		 'TutText': getTutText(context, view='')}
    return {'red':'',
             'main':main,
             'logged_in':logged_in,
             'form':importform.render(),
             'content':'',
             'name':'Import Requirements From CSV',
	     'TutText': getTutText(context, view='')}
开发者ID:C453,项目名称:yhs_nhs,代码行数:50,代码来源:userviews.py


示例10: add_independent_event

def add_independent_event(context,request):
    logged_in = authenticated_userid(request)
    user = find_root(request.context)['users'][logged_in]
    main = get_renderer('../templates/master.pt').implementation()
    schema = IndependentEventSchema()
    eventform = Form(schema, buttons=('submit',))
    if 'description' in request.params:
        try:
            controls = request.POST.items()
            captured = eventform.validate(controls)
        except deform.ValidationFailure, e:
            eventform = e.render()
            return {'red':'',
                    'main':main, 
                    'form':eventform, 
                    'content':'',
                    'logged_in':logged_in,
                    'name':'Add Independent Event',
		    'TutText': getTutText(user, view='')}
        completionDate = calendarstuff.datetime_from_str(request.params['completionDate'])
        hours = request.params['hours']
        description = request.params['description']
        taskDescription = request.params['taskDescription']
        contact = request.params['contact']
        contactInfo = request.params['contactInfo']
        affects = request.params['affects']
	type = request.params['type']
        context.eventcount += 1
        user = context.user
        event = Event("Independent",
                      type,
                      completionDate,
                      hours,
                      description,
                      taskDescription,
                      contact,contactInfo,
                      user,
                      context.eventcount,
                      affects=affects)
        event.__parent__ = context
        context[str(context.eventcount)]=event
        activitylog=find_root(context)['activityLogs']
        activitylog.event_creation(find_root(request.context)["users"][logged_in],event,request.application_url)
        return {'red':'serviceLogs/'+context.user.username,
                'main':main,
                'form':'',
                'content':"Added independent event for "+description,
                'logged_in':logged_in,
                'name':'Redirecting...',
		'TutText': getTutText(user, view='')}
开发者ID:C453,项目名称:yhs_nhs,代码行数:50,代码来源:eventviews.py


示例11: __call__

 def __call__(self, node, value):
     root = find_root(self.context)
     try:
         find_resource(root, value)
     except KeyError:
         raise colander.Invalid(
             node, _("Not an existing valid path."))
开发者ID:ArcheProject,项目名称:Arche,代码行数:7,代码来源:validators.py


示例12: dereference

 def dereference(self, context):
     """ Return the :class:`Object` this Reference refers to.
     ``context`` can be any resource and is simply used to find the root
     (which in turn is used to resolve the reference).
     """
     root = find_root(context)
     return root.get_object_for_reference(self)
开发者ID:sbrauer,项目名称:Audrey,代码行数:7,代码来源:reference.py


示例13: deferred_user_choices_widget

def deferred_user_choices_widget(node, kw):
    context = kw['context']
    root = find_root(context)
    user_choices = tuple(root['users'].keys())
    return deform.widget.AutocompleteInputWidget(size=20,
                                                 values = user_choices,
                                                 min_length=1)
开发者ID:GlobalActionPlan,项目名称:MadeToMeasure,代码行数:7,代码来源:system.py


示例14: at_userid_link

def at_userid_link(text, obj, request=None):
    """ Transform @userid to a link.
    """
    users = find_root(obj).users
    meeting = find_interface(obj, IMeeting)
    assert meeting
    if not request:
        request = get_current_request()

    def handle_match(matchobj):
        # The pattern contains a space so we only find usernames that 
        # has a whitespace in front, we save the spaced so we can but 
        # it back after the transformation
        space, userid = matchobj.group(1, 2)
        #Force lowercase userid
        userid = userid.lower()
        if userid in users: 
            user = users[userid]
    
            tag = {}
            tag['href'] = request.resource_url(meeting, '_userinfo', query={'userid': userid}).replace(request.application_url, '')
            tag['title'] = user.title
            tag['class'] = "inlineinfo"
            return space + HTML.a('@%s' % userid, **tag)
        else:
            return space + '@' + userid

    return re.sub(AT_PATTERN, handle_match, text)
开发者ID:tobsan,项目名称:voteit.core,代码行数:28,代码来源:helpers.py


示例15: groupfinder

def groupfinder(username, request):
    root = find_root(request.context)
    if username in root:
        return username
    else:
        # raise KeyError('Unknown user: %s' % username)
        return None
开发者ID:bennihepp,项目名称:pyGallerid,代码行数:7,代码来源:user.py


示例16: discussion_redirect_to_agenda_item

def discussion_redirect_to_agenda_item(context, request):
    root = find_root(context)
    ai = find_interface(context, IAgendaItem)
    if ai:
        path = resource_path(ai)
        
        query = dict(path = path,
                     content_type='DiscussionPost',
                     sort_index='created',
                     reverse=True,
                     limit=5, #FIXME: this should be globaly configurable?
                     )
        docids = root.catalog.search(**query)[1]
        
        # set to True if requested post is after the display limit
        after_limit = False
        
        get_metadata = root.catalog.document_map.get_metadata
        for docid in docids:
            brain = get_metadata(docid)
            if brain['uid'] == context.uid:
                after_limit = True
                break
            
        # post was not found among the displayed posts
        query = request.GET
        if not after_limit:
            query['discussions'] = 'all'
            url = request.resource_url(ai, query=query, anchor=context.uid)
        else:
            url = request.resource_url(ai, query=query, anchor=context.uid)
        return HTTPFound(location=url)
    
    raise NotFound("Couldn't locate Agenda Item from this context.")
开发者ID:tobsan,项目名称:voteit.core,代码行数:34,代码来源:redirect.py


示例17: libraries

 def libraries(self, status, biological_replicate_number,
               technical_replicate_number):
     if status == 'deleted':
         return []
     # Use root.get_by_uuid instead of embed to get reverse link
     # specifically. This helps avoid infinite loop since calculated
     # properties of experiment need to embed replicate.
     properties = self.upgrade_properties()
     root = find_root(self)
     experiment = root.get_by_uuid(properties['experiment'])
     libraries = set()
     for rep_uuid in experiment.get_rev_links('replicates'):
         rep_props = root.get_by_uuid(rep_uuid).upgrade_properties()
         # Only care (check and add to the list) about non-deleted technical
         # replicates of this replicate, meaning belonging to the same
         # biological replicate.
         if (rep_props['biological_replicate_number'] != biological_replicate_number
             or rep_props['status'] == 'deleted'):
             continue
         if rep_props['technical_replicate_number'] < technical_replicate_number:
             # Found smaller technical replicate, libraries will be
             # calculated there rather than here.
             return []
         if 'library' in rep_props:
             libraries.add(rep_props['library'])
     # This is the "first" techinical replicate within the isogenic
     # replciate. Therefore, libraries should be calculated.
     return list(libraries)
开发者ID:ENCODE-DCC,项目名称:encoded,代码行数:28,代码来源:experiment.py


示例18: get_font

 def get_font(self):
     try:
         font = traversal.find_resource(traversal.find_root(self.get_model()), self.font)
     except:
         return None
     else:
         return font
开发者ID:makeartweb,项目名称:makeartweb2,代码行数:7,代码来源:models.py


示例19: get_searchable_text

def get_searchable_text(context, default):
    root = find_root(context)
    catalog = root.catalog
    registry = get_current_registry()
    discriminators = list(getattr(registry, 'searchable_text_discriminators', ()))
    results = set()
    registry = get_current_registry()
    for index in registry.catalog_indexhelper['searchable_text'].linked:
        if index not in catalog: #pragma: no coverage
            # In case a bad name was linked in searchable_text, no reason to die because of it.
            continue
        disc = catalog[index].discriminator
        if isinstance(disc, string_types):
            attr_discriminator = _AttrDiscriminator(disc)
            discriminators.append(attr_discriminator)
        else:
            discriminators.append(catalog[index].discriminator)
    for discriminator in discriminators:
        res = discriminator(context, default)
        if res is default:
            continue
        if not isinstance(res, string_types):
            res = str(res)
        res = res.strip()
        if res:
            results.add(res)
    text = " ".join(results)
    text = text.strip()
    return text and text or default
开发者ID:ArcheProject,项目名称:Arche,代码行数:29,代码来源:catalog.py


示例20: view

 def view(self):
     song = self.context
     song = self.context
     root = find_root(song)
     if song.timings:
         words = list(krl_iterator(json.loads(song.timings)))
     else:
         words = []
     bw = mtbw(words)
     cards = carder(words, bw*2)
     divs = divver(cards)
     return {
         'title':song.title,
         'artist':song.artist,
         'num_likes':song.num_likes,
         'liked_by': song.liked_by,
         'recordings':song.recordings,
         'can_record':self.has_record_permission,
         'can_retime':self.has_edit_permission,
         "stream_url": self.request.resource_url(song, '@@stream'),
         "stream_type":song.mimetype,
         "timings": song.timings,
         "max_framerate": root.max_framerate,
         'karaoke_cards':divs,
         'mtbw':bw,
     }
开发者ID:notaliens,项目名称:youshouldsing,代码行数:26,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python traversal.quote_path_segment函数代码示例发布时间:2022-05-27
下一篇:
Python traversal.find_resource函数代码示例发布时间: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