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


Python interfaces.IObjectWillBeAddedEvent类代码示例

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


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

示例1: remove_ghosts

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)
开发者ID:quintagroup,项目名称:plone.app.multilingual,代码行数:31,代码来源:subscriber.py

示例2: onTreeSpanningComponentBeforeDelete

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)
开发者ID:SteelHouseLabs,项目名称:zenoss-prodbin,代码行数:25,代码来源:events.py

示例3: onDeviceDeleted

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()
开发者ID:zenoss,项目名称:ZenPacks.zenoss.OpenStackInfrastructure,代码行数:28,代码来源:Endpoint.py

示例4: handle_topic_deletion

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
开发者ID:eaudeweb,项目名称:naaya.Products.NaayaForum,代码行数:8,代码来源:subscribers.py

示例5: onOrganizerBeforeDelete

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))
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:8,代码来源:events.py

示例6: content_removed

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)
开发者ID:silvacms,项目名称:Products.Silva,代码行数:8,代码来源:order.py

示例7: onObjectRemoved

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)
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:8,代码来源:events.py

示例8: onInterfaceRemoved

def onInterfaceRemoved(ob, event):
    """
    Unindex
    """

    if not IObjectWillBeAddedEvent.providedBy(event):
        macs = ob.device().getMacAddressCache()
        if ob.macaddress in macs:
            macs.remove(ob.macaddress)
开发者ID:ssbunyk,项目名称:zenoss-prodbin,代码行数:9,代码来源:subscribers.py

示例9: unindexBeforeDelete

def unindexBeforeDelete(ob, event):
    """
    Multisubscriber for IIndexed + IObjectWillBeMovedEvent
    """
    if not IObjectWillBeAddedEvent.providedBy(event):
        if isinstance(ob, IpInterface):
            beforeDeleteIpInterface(ob, event)
        else:
            ob.unindex_object()
开发者ID:ssbunyk,项目名称:zenoss-prodbin,代码行数:9,代码来源:subscribers.py

示例10: handle_forum_deletion

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
开发者ID:eaudeweb,项目名称:naaya.Products.NaayaForum,代码行数:9,代码来源:subscribers.py

示例11: related_change_on_moving

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)
开发者ID:collective,项目名称:dexterity.localroles,代码行数:10,代码来源:subscriber.py

示例12: 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)
开发者ID:goschtl,项目名称:zope,代码行数:55,代码来源:test_TypesTool.py

示例13: onComponentRemoved

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)
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:11,代码来源:component_catalog.py

示例14: onDeviceDeleted

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
开发者ID:zenoss,项目名称:ZenPacks.zenoss.OpenStackInfrastructure,代码行数:12,代码来源:DeviceProxyComponent.py

示例15: related_change_on_moving

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)
开发者ID:collective,项目名称:dexterity.localrolesfield,代码行数:13,代码来源:subscriber.py


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