def content_removed(content, event): if (event.object != content or IObjectWillBeAddedEvent.providedBy(event) or event.newParent == event.oldParent): return if IOrderableContainer.providedBy(event.oldParent): manager = IOrderManager(event.oldParent) manager.remove(content)
def remove_ghosts(obj, event): """We are going to remove a object: we need to check if its neutral and remove their indexes also. """ if not IObjectWillBeAddedEvent.providedBy(event) \ and (IObjectWillBeMovedEvent.providedBy(event) or IObjectWillBeRemovedEvent.providedBy(event)): if not is_shared_original(obj): return content_id = IUUID(obj).split('-')[0] site = getSite() try: pc = getToolByName(site, 'portal_catalog') except AttributeError: # In case we are removing the site there is no portal_catalog return language_tool = getToolByName(site, 'portal_languages') language_infos = language_tool.supported_langs for language_info in language_infos: brains = pc.unrestrictedSearchResults( UID=content_id + '-' + language_info) for brain in brains: obj.unrestrictedTraverse(brain.getPath()).unindexObject() brains = pc.unrestrictedSearchResults( UID=content_id) for brain in brains: obj.unrestrictedTraverse(brain.getPath()).unindexObject() if IActionSucceededEvent.providedBy(event): reindex_neutral(obj, event)
def unindex(obj, event): """Un-index mirrored folder content for all mirrors and master Mirror folder content objects are indexed once for each mirror and the master with different, mirror-specific, UUID for each. When ever a mirrored folder content object is removed in some mirror or master, we must un-index it for all the other mirrors and master as well. """ if IObjectWillBeAddedEvent.providedBy(event): return if IPloneSiteRoot.providedBy(event.object): return info = mirror_info(obj) if info == NOT_MIRRORED: return uuid = IUUID(obj).split('@')[0] uuids = [uuid] + [f'{uuid}@{mirror_id}' for mirror_id in info.mirror_ids] cat = api.portal.get_tool('portal_catalog') for uuid in uuids: brains = cat.unrestrictedSearchResults(UID=uuid) for brain in brains: brain.getObject().unindexObject()
def onTreeSpanningComponentBeforeDelete(ob, event): """ When a component that links a device to another tree is going to be removed, update the device's paths. """ if not IObjectWillBeAddedEvent.providedBy(event): component = ob try: catalog = ob.getPhysicalRoot().zport.global_catalog except (KeyError, AttributeError): # Migrate script hasn't run yet; ignore indexing return device = component.device() if not device: # OS relation has already been broken; get by path path = component.getPrimaryPath() try: devpath = path[:path.index('devices')+2] device = component.unrestrictedTraverse(devpath) except ValueError: # We've done our best. Give up. return if device: oldpaths = devicePathsFromComponent(component) catalog.unindex_object_from_paths(device, oldpaths)
def onTreeSpanningComponentBeforeDelete(ob, event): """ When a component that links a device to another tree is going to be removed, update the device's paths. """ if not IObjectWillBeAddedEvent.providedBy(event): component = ob try: catalog = ob.getPhysicalRoot().zport.global_catalog except (KeyError, AttributeError): # Migrate script hasn't run yet; ignore indexing return device = component.device() if not device: # OS relation has already been broken; get by path path = component.getPrimaryPath() try: devpath = path[:path.index('devices') + 2] device = component.unrestrictedTraverse(devpath) except ValueError: # We've done our best. Give up. return if device: oldpaths = devicePathsFromComponent(component) catalog.unindex_object_from_paths(device, oldpaths)
def onDeviceDeleted(object, event): # Clean up any AMQP queues we may have created for this device. if not IObjectWillBeAddedEvent.providedBy(event): connectionInfo = getUtility(IAMQPConnectionInfo) queueSchema = getUtility(IQueueSchema) # For some reason, if an error gets thrown by queue_delete, it seems # to break the connection, so we'll just use a separate connection # for each call to it. for queue in ('$OpenStackInboundEvent', '$OpenStackInboundPerf'): queueName = substitute_replacements(queueSchema._queue_nodes[queue].name, {'device': object.id}) amqpClient = BlockingPublisher(connectionInfo, queueSchema) channel = amqpClient.getChannel() try: LOG.debug("Removing AMQP queue %s" % queueName) channel.queue_delete(queueName) LOG.info("Removed AMQP queue %s successfully." % queueName) except AMQPChannelException, e: # if the queue doesn't exist, don't worry about it. if e.amqp_reply_code == 404: LOG.debug('Queue %s did not exist', queueName) else: LOG.exception(e) amqpClient.close()
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.assertEqual(len(events), 4) evt = events[0] self.assertTrue(IObjectCreatedEvent.providedBy(evt)) self.assertEqual(evt.object, self.f.foo) evt = events[1] self.assertTrue(IObjectWillBeAddedEvent.providedBy(evt)) self.assertEqual(evt.object, self.f.foo) self.assertEqual(evt.oldParent, None) self.assertEqual(evt.oldName, None) self.assertEqual(evt.newParent, self.f) self.assertEqual(evt.newName, 'foo') evt = events[2] self.assertTrue(IObjectAddedEvent.providedBy(evt)) self.assertEqual(evt.object, self.f.foo) self.assertEqual(evt.oldParent, None) self.assertEqual(evt.oldName, None) self.assertEqual(evt.newParent, self.f) self.assertEqual(evt.newName, 'foo') evt = events[3] self.assertTrue(IContainerModifiedEvent.providedBy(evt)) self.assertEqual(evt.object, self.f)
def onObjectRemoved(ob, event): """ Unindex, please. """ if not IObjectWillBeAddedEvent.providedBy(event): object_to_unindex = _get_object_to_index(ob) if object_to_unindex: getUtility(IModelCatalog).uncatalog_object(object_to_unindex)
def onOrganizerBeforeDelete(ob, event): """ Before we delete the organizer we need to remove its references to the devices. """ if not IObjectWillBeAddedEvent.providedBy(event): for device in ob.devices.objectValuesGen(): notify(IndexingEvent(device, idxs='path', triggered_by_zope_event=True))
def handle_topic_deletion(ob, event): """The ForumTopic will be moved/removed""" if not IObjectWillBeAddedEvent.providedBy(event): # Object will be removed: # Same as above. If the topic is deleted by mistake the statistics #should still be there in case of undo. #ob.aq_inner.aq_parent.removeTopicHits(ob.id) pass
def object_will_be_moved(context, event): if not IObjectWillBeAddedEvent.providedBy(event): title = _(u'label_object_cut', default=u'Object cut: ${title}', mapping={'title': context.title_or_id()}) journal_entry_factory(context.aq_inner.aq_parent, OBJECT_WILL_BE_MOVED_EVENT, title) return
def unindexBeforeDelete(ob, event): """ Multisubscriber for IIndexed + IObjectWillBeMovedEvent """ if not IObjectWillBeAddedEvent.providedBy(event): if isinstance(ob, IpInterface): beforeDeleteIpInterface(ob, event) else: ob.unindex_object()
def handle_forum_deletion(ob, event): """The Forum will be moved/removed""" if not IObjectWillBeAddedEvent.providedBy(event): # Object will be removed: #Statistics db should not be removed. #If forum is undeleted then the statistics should still be there. #ob._removeStatisticsContainer() pass
def onInterfaceRemoved(ob, event): """ Unindex """ if not IObjectWillBeAddedEvent.providedBy(event): macs = ob.device().getMacAddressCache() if ob.macaddress in macs: macs.remove(ob.macaddress)
def related_change_on_moving(obj, event): """ Set local roles on related objects before moving """ if IObjectWillBeAddedEvent.providedBy(event) or IObjectWillBeRemovedEvent.providedBy(event): # not move return if event.oldParent and event.newParent and event.oldParent == event.newParent: # rename return (fti_config, fti) = fti_configuration(obj) if 'static_config' not in fti_config: return related_role_removal(obj, get_state(obj), fti_config)
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)
def onOrganizerBeforeDelete(ob, event): """ Before we delete the organizer we need to remove its references to the devices. """ if not IObjectWillBeAddedEvent.providedBy(event): for device in ob.devices.objectValuesGen(): notify( IndexingEvent(device, idxs='path', triggered_by_zope_event=True))
def onComponentRemoved(ob, event): if not IObjectWillBeAddedEvent.providedBy(event): spec = get_component_field_spec(ob.meta_type) if spec is None: return catalog = spec.get_catalog(ob, ob.meta_type) uid = '/'.join(ob.getPrimaryPath()) if catalog.getrid(uid) is None: # Avoid "tried to uncatalog nonexistent object" warnings return catalog.uncatalog_object(uid)
def onInterfaceRemoved(ob, event): """ Unindex """ if not IObjectWillBeAddedEvent.providedBy(event): device = ob.device() if device: macs = device.getMacAddressCache() if ob.macaddress in macs: macs.remove(ob.macaddress)
def onDeviceDeleted(object, event): ''' Clean up the dangling reference to a device if that device has been removed. (Note: we may re-create the device automatically next time someone calls self.ensure_proxy_device, though) ''' if not IObjectWillBeAddedEvent.providedBy(event) and not IObjectWillBeMovedEvent.providedBy(event): if hasattr(object, 'openstackProxyComponentUUID'): component = GUIDManager(object.dmd).getObject(getattr(object, 'openstackProxyComponentUUID', None)) if component: component.release_proxy_device() object.openstackProxyComponentUUID = None
def related_change_on_moving(obj, event): """ Set local roles on related objects before moving """ if IObjectWillBeAddedEvent.providedBy(event) or IObjectWillBeRemovedEvent.providedBy(event): # not move return if event.oldParent and event.newParent and event.oldParent == event.newParent: # rename return (fti_config, fti) = fti_configuration(obj) if not fti_config: return for (name, f) in get_localrole_fields(fti): if name not in fti_config: continue related_role_removal(obj, get_state(obj), fti_config[name], name)
def onDeviceDeleted(object, event): ''' Clean up the dangling reference to a device if that device has been removed. (Note: we may re-create the device automatically next time someone calls self.ensure_proxy_device, though) ''' if not IObjectWillBeAddedEvent.providedBy( event) and not IObjectWillBeMovedEvent.providedBy(event): if hasattr(object, 'openstackProxyComponentUUID'): component = GUIDManager(object.dmd).getObject( getattr(object, 'openstackProxyComponentUUID', None)) if component: component.release_proxy_device() object.openstackProxyComponentUUID = None
def related_change_on_moving(obj, event): """ Set local roles on related objects before moving """ if IObjectWillBeAddedEvent.providedBy( event) or IObjectWillBeRemovedEvent.providedBy(event): # not move return if event.oldParent and event.newParent and event.oldParent == event.newParent: # rename return (fti_config, fti) = fti_configuration(obj) if not fti_config: return for (name, f) in get_localrole_fields(fti): if name not in fti_config: continue related_role_removal(obj, get_state(obj), fti_config[name], name)
def object_will_be_moved(context, event): if IObjectWillBeAddedEvent.providedBy(event): return # Skip automatically renamed objects during copy & paste process. if ICopyPasteRequestLayer.providedBy(getRequest()): return title = _(u'label_object_cut', default=u'Object cut: ${title}', mapping={'title': context.title_or_id()}) journal_entry_factory(context.aq_inner.aq_parent, OBJECT_WILL_BE_MOVED_EVENT, title) return
def object_will_be_moved(context, event): if IObjectWillBeAddedEvent.providedBy(event): return # Skip automatically renamed objects during copy & paste process. if ICopyPasteRequestLayer.providedBy(getRequest()): return title = _(u'label_object_cut', default=u'Object cut: ${title}', mapping={'title': context.title_or_id()} ) journal_entry_factory( context.aq_inner.aq_parent, OBJECT_WILL_BE_MOVED_EVENT, title) return
def beforeDelete(self, event): """ This method is called, when the object is deleted. To support undo-functionality and because this happens too, when the object is moved (cut-paste) or renamed, the external file is not deleted. It is just renamed to filename.undo and remains in the repository, until it is deleted manually. Subscriber for (IExtFile, IObjectWillBeMovedEvent) """ from OFS.interfaces import IObjectWillBeAddedEvent # If this is an Add event we are done if IObjectWillBeAddedEvent.providedBy(event): return # Delete the disk file, i.e. rename it to .undo self._delete(self.filename)
def onOrganizerBeforeDelete(ob, event): """ Before we delete the organizer we need to remove its references to the devices. """ if not IObjectWillBeAddedEvent.providedBy(event): # get the catalog try: catalog = ob.getPhysicalRoot().zport.global_catalog except (KeyError, AttributeError): # Migrate script hasn't run yet; ignore indexing return # remove the device's path from this organizer # from the indexes for device in ob.devices.objectValuesGen(): catalog.unindex_object_from_paths(device, [device.getPhysicalPath()])
def onObjectRemoved(ob, event): """ Unindex, please. """ if not IObjectWillBeAddedEvent.providedBy(event): try: catalog = ob.getPhysicalRoot().zport.global_catalog except (KeyError, AttributeError): # Migrate script hasn't run yet; ignore indexing return path = ob.getPrimaryPath() # Ignore things dmd or above if len(path) <= 3 or path[2] != 'dmd': return uid = '/'.join(path) if catalog.getrid(uid) is None: return catalog.uncatalog_object(uid)
def onObjectRemoved(ob, event): """ Unindex, please. """ if not IObjectWillBeAddedEvent.providedBy(event): try: catalog = ob.getPhysicalRoot().zport.global_catalog except (KeyError, AttributeError): # Migrate script hasn't run yet; ignore indexing return path = ob.getPrimaryPath() # Ignore things dmd or above if len(path)<=3 or path[2]!='dmd': return uid = '/'.join(path) if catalog.getrid(uid) is None: return catalog.uncatalog_object(uid)
def onDeviceProxyComponentDeleted(object, event): ''' Clean up the dangling reference from a device if the component has been removed. ''' if not IObjectWillBeAddedEvent.providedBy(event): object.release_proxy_device()
def onTreeSpanningComponentBeforeDelete(ob, event): """ Before tree spanning component is deleted """ if not IObjectWillBeAddedEvent.providedBy(event): ppath = "/".join(ob.getPrimaryPath()) affected_objects = ObjectsAffectedBySpanningComponent(ob) affected_objects.index_affected_objects()
def changeMailingList(ml, event): """An event listener which registers and unregisters lists with the ListLookup utility on list changes. Some framework setup: >>> from zope.app.testing.placelesssetup import setUp, tearDown >>> import Products.Five >>> from Products.Five import zcml >>> setUp() >>> zcml.load_config('meta.zcml', package=Products.Five) >>> zcml.load_config('permissions.zcml', package=Products.Five) >>> zcml.load_config("configure.zcml", package=Products.Five.site) >>> from Products.listen.utilities import tests >>> zcml.load_config('configure.zcml', package=tests) Now let's make a fake mailing list in our site >>> from zope.app.component.hooks import setSite >>> app = self.folder >>> tests.enable_local_site(app) >>> setSite(app) >>> ml = tests.install_fake_ml(app, suppress_events=True) >>> setSite(ml) Then we setup our listener >>> from zope.app.event.interfaces import IObjectModifiedEvent >>> from zope.app.container.interfaces import IObjectMovedEvent >>> from OFS.interfaces import IObjectWillBeRemovedEvent >>> from Products.listen.utilities.list_lookup import changeMailingList >>> from zope.component import handle >>> from Products.listen.interfaces import IMailingList >>> handle([IMailingList, IObjectWillBeRemovedEvent], changeMailingList) >>> handle([IMailingList, IObjectMovedEvent], changeMailingList) >>> handle([IMailingList, IObjectModifiedEvent], changeMailingList) Create and register our utility. Have to do some faking of the component registry stuff to get our mock environment to work: >>> from Products.listen.interfaces import IListLookup >>> from Products.listen.utilities.list_lookup import ListLookup >>> from Products.listen.lib.common import get_utility_for_context >>> sm = app.getSiteManager() >>> sm.registerUtility(ListLookup('list_lookup'), IListLookup) >>> tests.register_fake_component_adapter() >>> ll = get_utility_for_context(IListLookup, context=app) >>> print ll.getListForAddress(ml.mailto) None Send our added event: >>> from zope.event import notify >>> from zope.app.container.contained import ObjectAddedEvent >>> notify(ObjectAddedEvent(ml, app, 'ml')) >>> ll.getListForAddress(ml.mailto) == ml True Change the list and send an event: >>> ml.mailto = '*****@*****.**' >>> from zope.app.event.objectevent import ObjectModifiedEvent >>> notify(ObjectModifiedEvent(ml)) >>> ll.getListForAddress(ml.mailto) == ml True Send a removal event, which should do nothing, as we rely on before removal: >>> from zope.app.container.contained import ObjectRemovedEvent >>> notify(ObjectRemovedEvent(ml, app, 'ml')) >>> ll.getListForAddress(ml.mailto) == ml True Send a before removal event: >>> from OFS.event import ObjectWillBeRemovedEvent >>> notify(ObjectWillBeRemovedEvent(ml)) >>> ll.getListForAddress(ml.mailto) is None True >>> tearDown() """ # Use the new parent object as the context, unless it is unavailable, then # use the list itself parent = None if hasattr(event, 'newParent'): parent = event.newParent if parent is None: parent = ml try: ll = getUtility(IListLookup) except ComponentLookupError: # site won't be set if you delete the Plone site from the ZMI orig_site = getSite() setSite(ml) ll = getUtility(IListLookup, context=ml) setSite(orig_site) if IObjectWillBeAddedEvent.providedBy(event): # Registration is taken care of after add pass elif IObjectWillBeRemovedEvent.providedBy(event): ll.unregisterList(ml) elif IObjectWillBeMovedEvent.providedBy(event): ll.unregisterList(ml) elif IObjectRemovedEvent.providedBy(event): # Unregistration is taken care of before removal pass elif IObjectModifiedEvent.providedBy(event): if not IContainerModifiedEvent.providedBy(event): ll.updateList(ml) elif IObjectAddedEvent.providedBy(event) or IObjectCreatedEvent.providedBy( event): ll.registerList(ml) elif IObjectMovedEvent.providedBy(event): ll.registerList(ml)
def unindex_removed_content(content, event): """We unindex all content that is going to be moved, and/or deleted. """ if not IObjectWillBeAddedEvent.providedBy(event): ICataloging(content).unindex()
def refireEventOnObjectBeforeRemove(object, event): if not IObjectWillBeAddedEvent.providedBy(event): guid = IGlobalIdentifier(object).guid notify(GUIDEvent(object, guid, None))
def object_will_be_moved(context, event): if not IObjectWillBeAddedEvent.providedBy(event): title = _(u"label_object_cut", default=u"Object cut: ${title}", mapping={"title": context.title_or_id()}) journal_entry_factory(context.aq_inner.aq_parent, OBJECT_WILL_BE_MOVED_EVENT, title) return
def changeMailingList(ml, event): """An event listener which registers and unregisters lists with the ListLookup utility on list changes. Some framework setup: >>> from zope.app.testing.placelesssetup import setUp, tearDown >>> import Products.Five >>> from Products.Five import zcml >>> setUp() >>> zcml.load_config('meta.zcml', package=Products.Five) >>> zcml.load_config('permissions.zcml', package=Products.Five) >>> zcml.load_config("configure.zcml", package=Products.Five.site) >>> from Products.listen.utilities import tests >>> zcml.load_config('configure.zcml', package=tests) Now let's make a fake mailing list in our site >>> from zope.app.component.hooks import setSite >>> app = self.folder >>> tests.enable_local_site(app) >>> setSite(app) >>> ml = tests.install_fake_ml(app, suppress_events=True) >>> setSite(ml) Then we setup our listener >>> from zope.app.event.interfaces import IObjectModifiedEvent >>> from zope.app.container.interfaces import IObjectMovedEvent >>> from OFS.interfaces import IObjectWillBeRemovedEvent >>> from Products.listen.utilities.list_lookup import changeMailingList >>> from zope.component import handle >>> from Products.listen.interfaces import IMailingList >>> handle([IMailingList, IObjectWillBeRemovedEvent], changeMailingList) >>> handle([IMailingList, IObjectMovedEvent], changeMailingList) >>> handle([IMailingList, IObjectModifiedEvent], changeMailingList) Create and register our utility. Have to do some faking of the component registry stuff to get our mock environment to work: >>> from Products.listen.interfaces import IListLookup >>> from Products.listen.utilities.list_lookup import ListLookup >>> from Products.listen.lib.common import get_utility_for_context >>> sm = app.getSiteManager() >>> sm.registerUtility(ListLookup('list_lookup'), IListLookup) >>> tests.register_fake_component_adapter() >>> ll = get_utility_for_context(IListLookup, context=app) >>> print ll.getListForAddress(ml.mailto) None Send our added event: >>> from zope.event import notify >>> from zope.app.container.contained import ObjectAddedEvent >>> notify(ObjectAddedEvent(ml, app, 'ml')) >>> ll.getListForAddress(ml.mailto) == ml True Change the list and send an event: >>> ml.mailto = '*****@*****.**' >>> from zope.app.event.objectevent import ObjectModifiedEvent >>> notify(ObjectModifiedEvent(ml)) >>> ll.getListForAddress(ml.mailto) == ml True Send a removal event, which should do nothing, as we rely on before removal: >>> from zope.app.container.contained import ObjectRemovedEvent >>> notify(ObjectRemovedEvent(ml, app, 'ml')) >>> ll.getListForAddress(ml.mailto) == ml True Send a before removal event: >>> from OFS.event import ObjectWillBeRemovedEvent >>> notify(ObjectWillBeRemovedEvent(ml)) >>> ll.getListForAddress(ml.mailto) is None True >>> tearDown() """ # Use the new parent object as the context, unless it is unavailable, then # use the list itself parent = None if hasattr(event, 'newParent'): parent = event.newParent if parent is None: parent = ml try: ll = getUtility(IListLookup) except ComponentLookupError: # site won't be set if you delete the Plone site from the ZMI orig_site = getSite() setSite(ml) ll = getUtility(IListLookup, context=ml) setSite(orig_site) if IObjectWillBeAddedEvent.providedBy(event): # Registration is taken care of after add pass elif IObjectWillBeRemovedEvent.providedBy(event): ll.unregisterList(ml) elif IObjectWillBeMovedEvent.providedBy(event): ll.unregisterList(ml) elif IObjectRemovedEvent.providedBy(event): # Unregistration is taken care of before removal pass elif IObjectModifiedEvent.providedBy(event): if not IContainerModifiedEvent.providedBy(event): ll.updateList(ml) elif IObjectAddedEvent.providedBy(event) or IObjectCreatedEvent.providedBy(event): ll.registerList(ml) elif IObjectMovedEvent.providedBy(event): ll.registerList(ml)
def onBeforeObjectDeleted(ob, event): """ Subscriber for IObjectEventsSubscriber + IObjectWillBeMovedEvent """ if not IObjectWillBeAddedEvent.providedBy(event): if hasattr(ob, "before_object_deleted_handler"): ob.before_object_deleted_handler()
def unindexBeforeDelete(ob, event): """ Multisubscriber for IIndexed + IObjectWillBeMovedEvent """ if not IObjectWillBeAddedEvent.providedBy(event): ob.unindex_object()
def beforeMoveNyContainer(obj, event): """A NyContainer will be moved.""" if not IObjectWillBeAddedEvent.providedBy(event): obj.uncatalogNyObject(obj)