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

Python traversal.find_interface函数代码示例

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

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



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


示例16: add_to_repo

def add_to_repo(obj, event):
    """
    Add a newly created object to the version repository.

    Intended use is as an IObjectAddedEvent subscriber.
    """
    if find_interface(obj, IIntranets):
        # Exclude /offices from repo
        return

    repo = find_repo(obj)
    if repo is None:
        return

    if not repo.history(obj.docid, True):
        # It is not in the repo, so add it
        adapter = queryAdapter(obj, IObjectVersion)
        if adapter is not None:
            if adapter.comment is None:
                adapter.comment = 'Content created.'
            repo.archive(adapter)

    container = event.parent
    adapter = queryAdapter(container, IContainerVersion)
    if adapter is not None:
        request = get_current_request()
        user = authenticated_userid(request)
        repo.archive_container(adapter, user)

    # Recurse into children if adding a subtree
    if IFolder.providedBy(obj):
        for name, child in obj.items():
            fake_event = FakeEvent()
            fake_event.parent = obj
            add_to_repo(child, fake_event)
开发者ID:Falmarri,项目名称:karl,代码行数:35,代码来源:subscribers.py


示例17: manage_questions

    def manage_questions(self):
        manage_questions.need()
        post = self.request.POST
        if 'cancel' in self.request.POST:
            url = self.request.resource_url(self.context)
            return HTTPFound(location = url)
        if 'save' in post:
            self.process_question_ids(self.context)
            self.add_flash_message(_('Updated'))

        self.response['organisation'] = org = find_interface(self.context, IOrganisation)

        picked_questions = set()
        survey_sections = []
        for section in self.context.values():
            if not ISurveySection.providedBy(section):
                continue
            picked_questions.update(section.question_ids)
            survey_sections.append(section)
        self.response['survey_sections'] = survey_sections
        if not survey_sections:
            msg = _(u"no_sections_added_notice",
                    default = u"You need to add survey sections and then use this view to manage the questions.")
            self.add_flash_message(msg)
        #Load all question objects that haven't been picked
        questions = org.questions
        self.response['available_questions'] = [questions[x] for x in questions if x not in picked_questions]
        return self.response
开发者ID:GlobalActionPlan,项目名称:MadeToMeasure,代码行数:28,代码来源:surveys.py


示例18: get_info

    def get_info(self, request):
        """Generate a sequence for the letter box, highlighting current"""

        # Get the letterbox data.  If the use has clicked on a letter, get
        # it from the URL and pass it into the function to get the data
        # for the letterbox macro, so we don't underline the current
        # letter.

        storage = find_interface(self.context, self.iface)
        current = request.params.get('titlestartswith', None)
        fmt = request.path_url + "?titlestartswith=%s"
        letters = []

        for letter in string.uppercase:
            if getattr(storage, 'alpha', None) and storage.alpha.get(letter):
                href = fmt % letter
            else:
                href = None
            if letter == current:
                css_class = 'current'
            else:
                css_class = 'notcurrent'
            letters.append({'name': letter,
                            'href': href,
                            'css_class': css_class,
                            'is_current': letter == current,
                           })
        letters.append({'name': 'Any',
                        'href': current is not None and
                                    request.path_url or None,
                        'css_class': current is None and
                                        'current' or 'notcurrent',
                        'is_current': current is None,
                       })
        return letters
开发者ID:claytron,项目名称:karl,代码行数:35,代码来源:adapters.py


示例19: object_removed

def object_removed(obj, event):
    """ Remove an index for a base content object. Also, remove all contained."""
    root = find_interface(obj, ISiteRoot)
    for child in find_all_base_content(obj):
        unindex_object(root.catalog, child)
    unindex_object(root.catalog, obj)
    _update_if_ai_parent(root.catalog, obj)
开发者ID:tobsan,项目名称:voteit.core,代码行数:7,代码来源:catalog.py


示例20: __init__

 def __init__(self, context, request):
     self.context = context
     self.request = request
     self.community = find_interface(context, ICommunity)
     self.profiles = find_profiles(context)
     self.api = TemplateAPI(context, request)
     self.filestore = get_filestore(context, request, 'accept-invitation')
开发者ID:claytron,项目名称:karl,代码行数:7,代码来源:members.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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