当前位置: 首页>>代码示例>>Python>>正文


Python traversal.find_interface函数代码示例

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


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

示例1: __init__

 def __init__(self, context, profile, request):
     super(BlogAlert, self).__init__(context, profile, request)
     self._community = find_community(context)
     blogentry = find_interface(context, IBlogEntry)
     if blogentry is None:
         # Comments can also be made against forum topics
         blogentry = find_interface(context, IForumTopic)
     self._blogentry = blogentry
开发者ID:Falmarri,项目名称:karl,代码行数:8,代码来源:adapters.py

示例2: overview

def overview(request):
    site_resource = find_resource(request.context, '/site/b')
    site_interface = find_interface(request.context, Site)
    camera = find_interface(request.context, Camera)
    txt = "{:s}\n{:s}\n{:s}\n{:s}".format(site_resource, site_interface, camera, request.context)
    response = Response(txt)
    response.content_type = 'text/plain'
    return response
开发者ID:openearth,项目名称:argus-python,代码行数:8,代码来源:views.py

示例3: __acl__

 def __acl__(self):
     meeting = find_interface(self, IMeeting)
     if meeting.get_workflow_state() == 'closed':
         return ACL['closed']
     ai = find_interface(self, IAgendaItem)
     ai_state = ai.get_workflow_state()
     #If ai is private, use private
     if ai_state == 'private':
         return ACL['private']
     return ACL['open']
开发者ID:tobsan,项目名称:voteit.core,代码行数:10,代码来源:discussion_post.py

示例4: __init__

 def __init__(self, key=None, parent=None,**kwargs):
     self.__name__ = key
     self.__parent__ = parent
     # Reference request
     self.request = find_root(self).request
     # Reference app and site
     self.__app__ = find_interface(self, i.IApp)
     self.__site__ = find_interface(self, i.ISite)
     # Assign kwargs to self (used as self.XXX not self['xxx'])
     for key in kwargs:
         setattr(self, key, kwargs[key])
开发者ID:kjq,项目名称:piano,代码行数:11,代码来源:base.py

示例5: __acl__

 def __acl__(self):
     meeting = find_interface(self, IMeeting)
     acl = get_acl_registry()
     if meeting.get_workflow_state() == 'closed':
         return acl.get_acl('DiscussionPost:closed')
     ai = find_interface(self, IAgendaItem)
     ai_state = ai.get_workflow_state()
     #If ai is private, use private
     if ai_state == 'private':
         return acl.get_acl('DiscussionPost:private')
     return acl.get_acl('DiscussionPost:open')
开发者ID:VoteIT,项目名称:voteit.core,代码行数:11,代码来源:discussion_post.py

示例6: __init__

 def __init__(self, context, profile, request):
     super(CommentAlert, self).__init__(context, profile, request)
     assert IComment.providedBy(context)
     self.alert = None
     if find_interface(self.context, IBlogEntry) or find_interface(context, IForumTopic):  # noqa
         # it is a blog alert
         self.alert = CommentBlogEntryAlert(self.context, self.profile, self.request)
     else:
         if find_interface(self.context, ICommunityFile):
             self.alert = CommunityFileCommentAlert(self.context, self.profile,
                                                    self.request)
开发者ID:lslaz1,项目名称:karl,代码行数:11,代码来源:adapters.py

示例7: _close_poll

 def _close_poll(self):
     request = self.request
     
     m = find_interface(self.poll, IMeeting)
     m.set_workflow_state(request, 'ongoing')
     
     ai = find_interface(self.poll, IAgendaItem)
     ai.set_workflow_state(request, 'upcoming')
     ai.set_workflow_state(request, 'ongoing')
     
     self.poll.set_workflow_state(request, 'upcoming')
     self.poll.set_workflow_state(request, 'ongoing')
     self.poll.set_workflow_state(request, 'closed')
开发者ID:VoteIT,项目名称:voteit.core,代码行数:13,代码来源:test_majority_poll.py

示例8: feed_discussion_post_added

def feed_discussion_post_added(obj, event):
    """ Will add a feed entry when a discussion post is added if agenda item is not private.
    """
    request = get_current_request()
    userid = authenticated_userid(request)
    agenda_item = find_interface(obj, IAgendaItem)
    if agenda_item.get_workflow_state() == "private":
        return
    msg = _(
        u"${userid} has written a post in ${agenda_item}.", mapping={"userid": userid, "agenda_item": agenda_item.title}
    )
    meeting = find_interface(obj, IMeeting)
    feed_handler = request.registry.getAdapter(meeting, IFeedHandler)
    feed_handler.add(obj.uid, msg, tags=("discussion_post", "added"))
开发者ID:VoteIT,项目名称:voteit.feed,代码行数:14,代码来源:subscribers.py

示例9: discussion_answer

    def discussion_answer(self):
        content_type = 'DiscussionPost'
        ai = find_interface(self.context, IAgendaItem)
        add_permission = self.api.content_types_add_perm(content_type)
        if not has_permission(add_permission, ai, self.request):
            raise HTTPForbidden("You're not allowed to add '%s' in this context." % content_type)
        
        schema_name = self.api.get_schema_name(content_type, 'add')
        schema = createSchema(schema_name).bind(context = self.context, request = self.request, api = self.api)
        
        url = self.request.resource_url(self.context, 'answer')
        form = Form(schema, 
                    action=url, 
                    buttons=(button_add,),
                    formid="answer-form-%s" % self.context.uid, 
                    use_ajax=False,
                    ajax_options=ajax_options)
        self.api.register_form_resources(form)
        
        self.response['user_image_tag'] = self.api.user_profile.get_image_tag(request = self.request)
        self.response['content_type'] = content_type
        
        post = self.request.POST
        if 'add' in post:
            controls = post.items()
            try:
                #appstruct is deforms convention. It will be the submitted data in a dict.
                appstruct = form.validate(controls)
            except ValidationFailure, e:
                self.response['form'] = e.render()
                if self.request.is_xhr:
                    return Response(render("templates/ajax_edit.pt", self.response, request = self.request))
                return self.response
            
            kwargs = {}
            kwargs['text'] = appstruct['text']
            if self.api.userid:
                kwargs['creators'] = [self.api.userid]

            ai = find_interface(self.context, IAgendaItem)
            
            obj = createContent(content_type, **kwargs)
            name = generate_slug(ai, obj.title)
            ai[name] = obj

            #Success, redirect
            url = self.request.resource_url(ai, anchor=obj.uid)
            if self.request.is_xhr:
                return Response(headers = [('X-Relocate', url)])
            return HTTPFound(location=url)
开发者ID:tobsan,项目名称:voteit.core,代码行数:50,代码来源:agenda_item.py

示例10: survey_dt

 def survey_dt(self):
     survey = find_interface(self.context, ISurvey)
     if not survey:
         return
     tz = survey.get_time_zone()
     loc = get_locale_name(self.request)
     return createObject('dt_helper', tz, loc)
开发者ID:GlobalActionPlan,项目名称:MadeToMeasure,代码行数:7,代码来源:base.py

示例11: get_navigation

def get_navigation(context, request, links):

    items = []

    for link in links:
        state = 'notcurrent'
        view_iface = link['view_iface']
        nav_ifaces = link['nav_ifaces']
        view_name = link['view_name']

        if view_iface.providedBy(context):
            if request.view_name == view_name:
                state = 'current'
        else:
            for nav_iface in nav_ifaces:
                if nav_iface.providedBy(context):
                    state = 'current'
                    break

        viewcontext = find_interface(context, view_iface)

        if viewcontext is not None:

            items.append(
                {'state':state,
                 'href':resource_url(viewcontext, request, view_name),
                 'title':link['title'],
                 })

    return items
开发者ID:mcdonc,项目名称:marlton,代码行数:30,代码来源:utils.py

示例12: course_module

 def course_module(self):
     if self.request.has_permission('perm:Edit', self.context):
         jqueryui.need()
         touchpunch_js.need()
     response = {}
     response['course'] = find_interface(self.context, ICourse)
     response['course_modules'] = response['course'].items()
     response['in_course'] = self.fikaProfile.in_course(response['course'])
     response['course_module_toggle'] = self._render_course_module_toggle
     response['course_pagination'] = render_course_pagination
     response['module_segments'] = self.context.values()
     response['is_assessment'] = {}
     for segment in self.context.values():
         response['is_assessment'][segment.__name__] = isinstance(segment, Assessment)
         if isinstance(segment, ImageSlideshow):
             lightbox_js.need()
             lightbox_css.need()
             break
         for segmentcontent in segment.values():
             if isinstance(segmentcontent, ImageSlideshow):
                 lightbox_js.need()
                 lightbox_css.need()
                 break
     response['addable_types'] = {}
     factories = get_content_factories(self.request.registry)
     for (obj, addable) in get_addable_content(self.request.registry).items():
         if 'Segment' in addable:
             factory = factories.get(obj, None)
             response['addable_types'][obj] = getattr(factory, 'icon', 'file')
     return response
开发者ID:FikaProject,项目名称:fika,代码行数:30,代码来源:course_module.py

示例13: proposal_redirect_to_agenda_item

def proposal_redirect_to_agenda_item(context, request):
    ai = find_interface(context, IAgendaItem)
    if ai:
        query = request.GET
        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,代码行数:7,代码来源:redirect.py

示例14: jquery_member_search_view

def jquery_member_search_view(context, request):
    prefix = request.params['val'].lower()
    community = find_interface(context, ICommunity)
    member_names = community.member_names
    moderator_names = community.moderator_names
    community_member_names = member_names.union(moderator_names)
    query = dict(
        member_name='%s*' % prefix,
        sort_index='title',
        limit=20,
        )
    searcher = ICatalogSearch(context)
    try:
        total, docids, resolver = searcher(**query)
        profiles = filter(None, map(resolver, docids))
        records = [dict(
                    id = profile.__name__,
                    text = profile.title,
                    )
                   for profile in profiles
                   if profile.__name__ not in community_member_names
                   and profile.security_state != 'inactive']
    except ParseError:
        records = []
    result = JSONEncoder().encode(records)
    return Response(result, content_type="application/x-json")
开发者ID:claytron,项目名称:karl,代码行数:26,代码来源:members.py

示例15: notify_policycompass

def notify_policycompass(event):
    """Push comments of IExternalResource ressources to elastic search."""
    comment = event.object
    external_resource = find_interface(comment, IExternalResource)

    if external_resource is None:
        return

    resource_name = get_sheet_field(external_resource, IName, 'name')
    match = re.match(
        '(?P<type>visualization|event|dataset|metric|model|indicator)'
        '_(?P<id>[0-9]+)',
        resource_name)

    # this is not a known policycompass external resource
    if match is None:
        return

    resource_type = match.group('type')
    resource_id = match.group('id')

    settings = event.registry.settings
    pcompass_endpoint = settings.get('adhocracy_pcompass.pcompass_endpoint',
                                     'http://localhost:8000')
    url = '{base}/api/v1/searchmanager/updateindexitem/{res_type}/{res_id}' \
        .format(base=pcompass_endpoint,
                res_type=resource_type,
                res_id=resource_id)

    r = requests.post(url)
    if r.status_code != 200:  # indexing error on pcompass
        msg = 'Notifying policy compass about "{}_{}" failed with "{}"'.format(
            resource_type, resource_type, r.text)
        raise ValueError(msg)
开发者ID:fhartwig,项目名称:adhocracy3.mercator,代码行数:34,代码来源:subscriber.py


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