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


Python IObjectAddedEvent.providedBy方法代码示例

本文整理汇总了Python中zope.container.interfaces.IObjectAddedEvent.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python IObjectAddedEvent.providedBy方法的具体用法?Python IObjectAddedEvent.providedBy怎么用?Python IObjectAddedEvent.providedBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zope.container.interfaces.IObjectAddedEvent的用法示例。


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

示例1: movedCustomUser

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
def movedCustomUser(ob, event):
    """A CustomUser was moved.
    """
    if not IObjectRemovedEvent.providedBy(event):
        return
    if not IObjectAddedEvent.providedBy(event):
        removedCustomUser(ob, event)
开发者ID:groupserver,项目名称:Products.CustomUserFolder,代码行数:9,代码来源:CustomUser.py

示例2: onObjectMoved

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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))
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:9,代码来源:events.py

示例3: onObjectMoved

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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))
开发者ID:SteelHouseLabs,项目名称:zenoss-prodbin,代码行数:9,代码来源:events.py

示例4: log_move

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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()
开发者ID:silvacms,项目名称:silva.security.logging,代码行数:10,代码来源:subscribers.py

示例5: movedFile

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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)
开发者ID:groupserver,项目名称:Products.XWFFileLibrary2,代码行数:11,代码来源:XWFFile2.py

示例6: reconfigureChildRegistry

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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)
开发者ID:collective,项目名称:collective.behavior.localregistry,代码行数:12,代码来源:subscribers.py

示例7: test_events

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
    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,代码行数:57,代码来源:test_TypesTool.py

示例8: handleOpaqueItemEvent

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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)
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:19,代码来源:CMFCatalogAware.py

示例9: content_moved

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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'})
开发者ID:silvacms,项目名称:silva.app.redirectlink,代码行数:23,代码来源:link.py

示例10: handleContentishEvent

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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()
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:24,代码来源:CMFCatalogAware.py

示例11: handleUidAnnotationEvent

# 需要导入模块: from zope.container.interfaces import IObjectAddedEvent [as 别名]
# 或者: from zope.container.interfaces.IObjectAddedEvent import providedBy [as 别名]
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)
开发者ID:goschtl,项目名称:zope,代码行数:41,代码来源:UniqueIdAnnotationTool.py


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