本文整理汇总了Python中ZPublisher.BeforeTraverse.registerBeforeTraverse方法的典型用法代码示例。如果您正苦于以下问题:Python BeforeTraverse.registerBeforeTraverse方法的具体用法?Python BeforeTraverse.registerBeforeTraverse怎么用?Python BeforeTraverse.registerBeforeTraverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZPublisher.BeforeTraverse
的用法示例。
在下文中一共展示了BeforeTraverse.registerBeforeTraverse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例2: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例3: _update
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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
示例4: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例5: _edit
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例6: test_json_request_on_object_with_multihook
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例7: test_app_layer_enabled_directly
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例8: movedNySite
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例9: handleCookieCrumblerEvent
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例10: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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
示例11: _edit
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
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)
示例12: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
def manage_afterAdd(self, item, container):
if item is self and self.getPortalType() == 'Web Section':
handle = self.meta_type + '/' + self.getId()
BeforeTraverse.registerBeforeTraverse(item, WebSectionTraversalHook(), handle)
super(WebSection, self).manage_afterAdd(item, container)
示例13: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
def manage_afterAdd(self, item, container):
if item is self:
handle = self.meta_type + '/' + self.getId()
BeforeTraverse.registerBeforeTraverse(item, WebSiteTraversalHook(), handle)
WebSection.manage_afterAdd(self, item, container)
示例14: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
def manage_afterAdd(self, item, container):
if item is self:
handle = self.meta_type + '/' + self.id
container = container.this()
nc = BeforeTraverse.NameCaller(self.id)
BeforeTraverse.registerBeforeTraverse(container, nc, handle)
示例15: manage_afterAdd
# 需要导入模块: from ZPublisher import BeforeTraverse [as 别名]
# 或者: from ZPublisher.BeforeTraverse import registerBeforeTraverse [as 别名]
def manage_afterAdd(self, item, container):
if item is self:
handle = self.meta_type + '/' + self.getId()
BeforeTraverse.registerBeforeTraverse(item, self._getTraversalHookClass()(), handle)
super(WebSection, self).manage_afterAdd(item, container)