當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。