本文整理汇总了Python中zope.container.interfaces.IObjectAddedEvent类的典型用法代码示例。如果您正苦于以下问题:Python IObjectAddedEvent类的具体用法?Python IObjectAddedEvent怎么用?Python IObjectAddedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IObjectAddedEvent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: movedCustomUser
def movedCustomUser(ob, event):
"""A CustomUser was moved.
"""
if not IObjectRemovedEvent.providedBy(event):
return
if not IObjectAddedEvent.providedBy(event):
removedCustomUser(ob, event)
示例2: onObjectMoved
def onObjectMoved(ob, event):
"""
Reindex paths only
"""
if not (IObjectAddedEvent.providedBy(event) or
IObjectRemovedEvent.providedBy(event)):
notify(IndexingEvent(ob, idxs='path', triggered_by_zope_event=True))
示例3: onObjectMoved
def onObjectMoved(ob, event):
"""
Reindex paths only, don't update metadata.
"""
if not (IObjectAddedEvent.providedBy(event) or
IObjectRemovedEvent.providedBy(event)):
notify(IndexingEvent(ob, 'path', False))
示例4: log_move
def log_move(content, event):
if content is event.object:
if not (IObjectAddedEvent.providedBy(event) or
IObjectRemovedEvent.providedBy(event)):
detail = 'from %s/%s to %s/%s' % (
get_path(event.oldParent), event.oldName,
get_path(event.newParent), event.newName)
LoggingEvent('move', content, detail).log()
示例5: movedFile
def movedFile(ob, event):
"""A File was moved in the storage.
"""
if not IObjectRemovedEvent.providedBy(event):
#raise NotImplementedError # we don't support moving
return
if not IObjectAddedEvent.providedBy(event):
removedFile(ob, event)
示例6: reconfigureChildRegistry
def reconfigureChildRegistry(context, event):
""" Upon moving or renaming an object, the registry must be reconfigured.
Under the hood, this will re-register compoents with the correct paths
to prevent errors.
"""
# Ignore removal, and we already catch added events above
if not IObjectRemovedEvent.providedBy(event) \
and not IObjectAddedEvent.providedBy(event):
enableChildRegistry(context, event)
示例7: test_events
def test_events(self):
from OFS.interfaces import IObjectWillBeAddedEvent
from zope.component import adapter
from zope.component import provideHandler
from zope.container.interfaces import IContainerModifiedEvent
from zope.container.interfaces import IObjectAddedEvent
from zope.lifecycleevent.interfaces import IObjectCreatedEvent
events = []
@adapter(IObjectCreatedEvent)
def _handleObjectCreated(event):
events.append(event)
provideHandler(_handleObjectCreated)
@adapter(IObjectWillBeAddedEvent)
def _handleObjectWillBeAdded(event):
events.append(event)
provideHandler(_handleObjectWillBeAdded)
@adapter(IObjectAddedEvent)
def _handleObjectAdded(event):
events.append(event)
provideHandler(_handleObjectAdded)
@adapter(IContainerModifiedEvent)
def _handleContainerModified(event):
events.append(event)
provideHandler(_handleContainerModified)
self.ti.constructInstance(self.f, 'foo')
self.assertEquals(len(events), 4)
evt = events[0]
self.failUnless(IObjectCreatedEvent.providedBy(evt))
self.assertEquals(evt.object, self.f.foo)
evt = events[1]
self.failUnless(IObjectWillBeAddedEvent.providedBy(evt))
self.assertEquals(evt.object, self.f.foo)
self.assertEquals(evt.oldParent, None)
self.assertEquals(evt.oldName, None)
self.assertEquals(evt.newParent, self.f)
self.assertEquals(evt.newName, 'foo')
evt = events[2]
self.failUnless(IObjectAddedEvent.providedBy(evt))
self.assertEquals(evt.object, self.f.foo)
self.assertEquals(evt.oldParent, None)
self.assertEquals(evt.oldName, None)
self.assertEquals(evt.newParent, self.f)
self.assertEquals(evt.newName, 'foo')
evt = events[3]
self.failUnless(IContainerModifiedEvent.providedBy(evt))
self.assertEquals(evt.object, self.f)
示例8: handleOpaqueItemEvent
def handleOpaqueItemEvent(ob, event):
""" Event subscriber for (ICallableOpaqueItemEvents, IObjectEvent) events.
"""
if IObjectAddedEvent.providedBy(event):
if event.newParent is not None:
ob.manage_afterAdd(ob, event.newParent)
elif IObjectClonedEvent.providedBy(event):
ob.manage_afterClone(ob)
elif IObjectMovedEvent.providedBy(event):
if event.newParent is not None:
ob.manage_afterAdd(ob, event.newParent)
elif IObjectWillBeMovedEvent.providedBy(event):
if event.oldParent is not None:
ob.manage_beforeDelete(ob, event.oldParent)
示例9: content_moved
def content_moved(content, event):
# We only do if the object is the target of the event.
if event.object is not content:
return
# Don't create a link if it's an add or remove event.
if IObjectRemovedEvent.providedBy(event) or \
IObjectAddedEvent.providedBy(event):
return
# The content might not want redirect link.
if INoPermanentRedirectLink.providedBy(content):
return
# The extension is not activated.
if not content.service_extensions.is_installed("silva.app.redirectlink"):
return
container = event.oldParent
factory = container.manage_addProduct['silva.app.redirectlink']
factory.manage_addPermanentRedirectLink(event.oldName, content.get_title())
link = getattr(container, event.oldName)
link.set_target(content)
binding = getUtility(IMetadataService).getMetadata(link)
binding.setValues('silva-settings', {'hide_from_tocs': 'hide'})
示例10: handleContentishEvent
def handleContentishEvent(ob, event):
""" Event subscriber for (IContentish, IObjectEvent) events.
"""
if IObjectAddedEvent.providedBy(event):
ob.notifyWorkflowCreated()
ob.indexObject()
elif IObjectMovedEvent.providedBy(event):
if event.newParent is not None:
ob.indexObject()
elif IObjectWillBeMovedEvent.providedBy(event):
if event.oldParent is not None:
ob.unindexObject()
elif IObjectCopiedEvent.providedBy(event):
if hasattr(aq_base(ob), 'workflow_history'):
del ob.workflow_history
elif IObjectCreatedEvent.providedBy(event):
if hasattr(aq_base(ob), 'addCreator'):
ob.addCreator()
示例11: handleUidAnnotationEvent
def handleUidAnnotationEvent(ob, event):
""" Event subscriber for (IContentish, IObjectEvent) events
"""
if IObjectAddedEvent.providedBy(event):
if event.newParent is not None:
anno_tool = queryUtility(IUniqueIdAnnotationManagement)
uidtool = queryUtility(IUniqueIdHandler)
if anno_tool is not None:
remove_on_add = anno_tool.getProperty('remove_on_add', False)
remove_on_clone = anno_tool.getProperty('remove_on_clone', False)
assign_on_add = anno_tool.getProperty('assign_on_add', False)
if (remove_on_add and remove_on_clone) or assign_on_add:
try:
uidtool.unregister(ob)
except UniqueIdError:
# did not have one
pass
if assign_on_add:
# assign new uid
uidtool.register(ob)
elif IObjectClonedEvent.providedBy(event):
anno_tool = queryUtility(IUniqueIdAnnotationManagement)
uidtool = queryUtility(IUniqueIdHandler)
if anno_tool is not None:
remove_on_clone = anno_tool.getProperty('remove_on_clone', False)
assign_on_clone = anno_tool.getProperty('assign_on_clone', False)
if remove_on_clone or assign_on_clone:
try:
uidtool.unregister(ob)
except UniqueIdError:
# did not have one
pass
if assign_on_clone:
# assign new uid
uidtool.register(ob)