• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python interfaces.IObjectWillBeAddedEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: beforeDelete

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)
开发者ID:clearwired,项目名称:Blend-CMS,代码行数:17,代码来源:ExtFile.py


示例17: onOrganizerBeforeDelete

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


示例18: onObjectRemoved

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


示例19: unindex_removed_content

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


示例20: object_will_be_moved

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
开发者ID:hellfish2,项目名称:opengever.core,代码行数:6,代码来源:handlers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python interfaces.IObjectWillBeMovedEvent类代码示例发布时间:2022-05-24
下一篇:
Python SimpleItem.SimpleItem类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap