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


Python ZPublisher.BeforeTraverse类代码示例

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


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

示例1: manage_afterAdd

    def manage_afterAdd(self, item, container):
        if item is self:
            container.__allow_groups__ = aq_base(self)

            handle = self.meta_type + '/' + self.getId()
            container = container.this()
            nc = BeforeTraverse.NameCaller(self.getId())
            BeforeTraverse.registerBeforeTraverse(container, nc, handle)
开发者ID:goschtl,项目名称:zope,代码行数:8,代码来源:PluggableAuthService.py

示例2: _cleanupBeforeTraverseHooks

 def _cleanupBeforeTraverseHooks(self):
   # unregister all before traversal hooks that do not belong to us.
   my_handle = self.meta_type + '/' + self.getId()
   handle_to_unregister_list = []
   for (priority, handle), hook in self.__before_traverse__.items():
     if isinstance(hook, self._getTraversalHookClass()) and handle != my_handle:
       handle_to_unregister_list.append(handle)
   for handle in handle_to_unregister_list:
     BeforeTraverse.unregisterBeforeTraverse(self, handle)
开发者ID:ccwalkerjm,项目名称:erp5,代码行数:9,代码来源:WebSection.py

示例3: manage_beforeDelete

    def manage_beforeDelete(self, item, container):
        if item is self:
            try:
                del container.__allow_groups__
            except:
                pass

            handle = self.meta_type + '/' + self.getId()
            BeforeTraverse.unregisterBeforeTraverse(container, handle)
开发者ID:goschtl,项目名称:zope,代码行数:9,代码来源:PluggableAuthService.py

示例4: manage_afterAdd

    def manage_afterAdd(self, item, container):
        if item is self:
            id = self.id
            if callable(id):
                id = id()

            # We want the original object, not stuff in between
            container = container.this()
            hook = BeforeTraverse.NameCaller(id)
            BeforeTraverse.registerBeforeTraverse(container, hook, self.meta_type, self.priority)
开发者ID:wpjunior,项目名称:proled,代码行数:10,代码来源:SiteRoot.py

示例5: _update

 def _update(self, portal):
     traversers = portal.__before_traverse__
     for priority, name in traversers.keys():
         if portal.getId() in name:
             self.log.debug('Fix not needed')
             return
     name_caller = BeforeTraverse.NameCaller(portal.getId())
     app_handle = '%s/%s' % (portal.meta_type, portal.getId())
     BeforeTraverse.registerBeforeTraverse(portal, name_caller, app_handle)
     self.log.debug('Fix applied!')
     return True
开发者ID:eaudeweb,项目名称:naaya.updater,代码行数:11,代码来源:update_fix_login.py

示例6: _edit

 def _edit(self, **kw):
   # XXX it is unclear if we should keep this behavior in other potential subclasses.
   # Probably yes.
   if self.getPortalType() in ('Web Section', 'Web Site'):
     if getattr(self, '__before_traverse__', None) is None:
       # migrate beforeTraverse hook if missing
       handle = self.meta_type + '/' + self.getId()
       BeforeTraverse.registerBeforeTraverse(self, self._getTraversalHookClass()(), handle)
     else:
       # cleanup beforeTraverse hooks that may exist after this document was cloned.
       self._cleanupBeforeTraverseHooks()
   super(WebSection, self)._edit(**kw)
开发者ID:ccwalkerjm,项目名称:erp5,代码行数:12,代码来源:WebSection.py

示例7: manage_afterAdd

    def manage_afterAdd(self, item, container):
        if item is self:
            if BeforeTraverse.queryBeforeTraverse(container, self.meta_type):
                raise BadRequest, ("This container already has a %s" % self.meta_type)
            id = self.id
            if callable(id):
                id = id()

            # We want the original object, not stuff in between
            container = container.this()
            hook = BeforeTraverse.NameCaller(id)
            BeforeTraverse.registerBeforeTraverse(container, hook, self.meta_type, self.priority)
开发者ID:wpjunior,项目名称:proled,代码行数:12,代码来源:VirtualHostMonster.py

示例8: test_json_request_on_object_with_multihook

    def test_json_request_on_object_with_multihook(self):
        doc1 = self.portal[self.portal.invokeFactory('Document', id='doc1')]

        # Register a function to be called before traversal
        def btr_test(container, request):
            request._btr_test_called = 1
        doc1.btr_test = btr_test
        nc = BeforeTraverse.NameCaller('btr_test')
        BeforeTraverse.registerBeforeTraverse(doc1, nc, 'Document/btr_test')

        obj = self.traverse(path='/plone/doc1')
        self.assertTrue(isinstance(obj, Service), 'Not a service')
        self.assertEquals(1, self.request._btr_test_called)
开发者ID:plone,项目名称:plone.rest,代码行数:13,代码来源:test_traversal.py

示例9: test_app_layer_enabled_directly

    def test_app_layer_enabled_directly(self):
        folder = api.content.create(container=self.portal,
                                    type='Folder',
                                    title='testfolder')
        api.content.transition(folder, 'publish')
        directlyProvides(folder, IMockFolder)
        folder.app_layers = (IMockLayer,)
        BeforeTraverse.registerBeforeTraverse(folder,
                                              enable_app_layer(),
                                              'enable_app_layer')
        transaction.commit()

        browser = Browser(self.app)
        browser.open("%s/@@browser_layers" % folder.absolute_url())
        self.assertTrue('ploneintranet.layout.tests.utils.IMockLayer'
                        in browser.contents)
开发者ID:smcmahon,项目名称:ploneintranet,代码行数:16,代码来源:test_layers.py

示例10: movedNySite

def movedNySite(ob, event):
    """ A NySite was moved """
    if IObjectAddedEvent.providedBy(event):

        #Hadled by addedNySite
        return
    elif IObjectRemovedEvent.providedBy(event):

        #Hadled by removedNySite
        return
    else:
        old_handle = ob.meta_type + '/' + event.oldName
        BeforeTraverse.unregisterBeforeTraverse(ob, old_handle)
        handle = ob.meta_type + '/' + event.newName
        nc = BeforeTraverse.NameCaller(event.newName)
        BeforeTraverse.registerBeforeTraverse(ob, nc, handle)
开发者ID:bogtan,项目名称:Naaya,代码行数:16,代码来源:events.py

示例11: handleCookieCrumblerEvent

def handleCookieCrumblerEvent(ob, event):
    """ Event subscriber for (un)registering a CC as a before traverse hook.
    """
    if not ICookieCrumbler.providedBy(ob):
        return

    if IObjectMovedEvent.providedBy(event):
        if event.newParent is not None:
            # register before traverse hook
            handle = ob.meta_type + '/' + ob.getId()
            nc = BeforeTraverse.NameCaller(ob.getId())
            BeforeTraverse.registerBeforeTraverse(event.newParent, nc, handle)
    elif IObjectWillBeMovedEvent.providedBy(event):
        if event.oldParent is not None:
            # unregister before traverse hook
            handle = ob.meta_type + '/' + ob.getId()
            BeforeTraverse.unregisterBeforeTraverse(event.oldParent, handle)
开发者ID:goschtl,项目名称:zope,代码行数:17,代码来源:CookieCrumbler.py

示例12: manage_afterAdd

    def manage_afterAdd(self, item, container):
        """ after add event """
        if item is self:
            handle = self.meta_type + '/' + self.getId()
            nc = BeforeTraverse.NameCaller(self.getId())
            BeforeTraverse.registerBeforeTraverse(container, nc, handle)
        self.loadDefaultRoles()
        try:
            self.createRepository()
            style_css = open(join(DOCMANAGER_PRODUCT_PATH,'zpt','DocManager','DocManager_style.zpt'))
            content = style_css.read()
            style_css.close()
            manage_addPageTemplate(self, id=DOCMANAGER_CSS, title='', text=content)

            style_css = open(join(DOCMANAGER_PRODUCT_PATH,'zpt','DocManager','DocManager_template.zpt'))
            content = style_css.read()
            style_css.close()
            manage_addPageTemplate(self, id=DOCMANAGER_TEMPLATE, title='', text=content)

            Folder.inheritedAttribute('manage_afterAdd')(self, item, container)
        except:
            pass
开发者ID:eaudeweb,项目名称:naaya,代码行数:22,代码来源:DocManager.py

示例13: manage_beforeDelete

 def manage_beforeDelete(self, item, container):
     if item is self:
         BeforeTraverse.unregisterBeforeTraverse(container, self.meta_type)
开发者ID:wpjunior,项目名称:proled,代码行数:3,代码来源:SiteRoot.py

示例14: manage_beforeDelete

 def manage_beforeDelete(self, item, container):
     if item is self:
         handle = self.meta_type + '/' + self.getId()
         BeforeTraverse.unregisterBeforeTraverse(container, handle)
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:4,代码来源:LanguageTool.py

示例15: _edit

 def _edit(self, **kw):
   # migrate beforeTraverse hook if missing
   if getattr(self, '__before_traverse__', None) is None and self.getPortalType() == 'Web Section':
     handle = self.meta_type + '/' + self.getId()
     BeforeTraverse.registerBeforeTraverse(self, WebSectionTraversalHook(), handle)
   super(WebSection, self)._edit(**kw)
开发者ID:Verde1705,项目名称:erp5,代码行数:6,代码来源:WebSection.py


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