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


Python IContainerModifiedEvent.providedBy方法代码示例

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


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

示例1: testRenameEvents

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
    def testRenameEvents(self):
        self.assertRaises(KeyError, self.reflecto.manage_renameObjects,
                          ('monty',), ('python',))
        self.assertEqual(len(getEvents()), 0)

        self.assertRaises(KeyError, self.reflecto.manage_renameObjects,
                          ('foo', 'monty'), ('bar', 'python'))
        self.assertEqual(len(getEvents()), 1)
        events = getEvents(IObjectWillBeMovedEvent)
        self.assertEqual(len(events), 1)
        self.assertEqual(events[0].oldName, 'foo')
        self.assertEqual(events[0].newName, 'bar')

        self.assertEqual(self.reflecto.manage_renameObjects(('foo',), ('bar',)),
                         ['foo'])
        events = getEvents()
        self.assertEqual(len(events), 4)
        self.assertTrue(IObjectWillBeMovedEvent.providedBy(events[1]))

        self.assertTrue(IObjectMovedEvent.providedBy(events[2]))
        self.assertEqual(events[2].oldName, 'foo')
        self.assertEqual(events[2].newName, 'bar')

        self.assertTrue(IContainerModifiedEvent.providedBy(events[3]))
        self.assertTrue(events[3].object is self.reflecto)
开发者ID:FHNW,项目名称:Products.Reflecto,代码行数:27,代码来源:testDirectory.py

示例2: sync_task

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def sync_task(obj, event):
    """Index the given task in opengever.globalindex.
    """
    if IContainerModifiedEvent.providedBy(event):
        return

    TaskSqlSyncer(obj, event).sync()
开发者ID:4teamwork,项目名称:opengever.core,代码行数:9,代码来源:task.py

示例3: test_events

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent 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

示例4: testCutEvents

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
    def testCutEvents(self):
        cp = self.reflecto.manage_cutObjects(('foo',))
        self.reflecto['subdir'].manage_pasteObjects(cp)

        events = getEvents()
        self.assertEqual(len(events), 4)

        self.assertTrue(IObjectWillBeMovedEvent.providedBy(events[0]))
        self.assertEqual(events[0].oldName, 'foo')
        self.assertEqual(events[0].oldParent, self.reflecto)
        self.assertEqual(events[0].newName, 'foo')
        self.assertEqual(events[0].newParent, self.reflecto['subdir'])

        self.assertTrue(IObjectMovedEvent.providedBy(events[1]))
        self.assertEqual(events[1].object.getId(), 'foo')

        self.assertTrue(IContainerModifiedEvent.providedBy(events[2]))
        self.assertEqual(events[2].object, self.reflecto)
        self.assertTrue(IContainerModifiedEvent.providedBy(events[3]))
        self.assertEqual(events[3].object, self.reflecto['subdir'])
开发者ID:FHNW,项目名称:Products.Reflecto,代码行数:22,代码来源:testDirectory.py

示例5: propagate_vocab_restrictions_to_children

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def propagate_vocab_restrictions_to_children(container, event):
    if ILocalrolesModifiedEvent.providedBy(event) or \
       IContainerModifiedEvent.providedBy(event):
        return

    restricted_fields = [
        IClassification['classification'],
        IClassification['privacy_layer']]

    propagate_vocab_restrictions(
        container, event, restricted_fields, IClassificationMarker)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:13,代码来源:classification.py

示例6: index_and_update_author_modified_content

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def index_and_update_author_modified_content(content, event):
    """A content have been created of modifed. Update its author
    information.
    """
    # In the same way, we discard event on versioned content if they
    # are about adding or removing a version.
    if IVersionedContent.providedBy(content) and IContainerModifiedEvent.providedBy(event):
        return
    if getattr(content, "__initialization__", False):
        return
    ChangesTask.get().modified(content)
    ICataloging(content).reindex()
开发者ID:silvacms,项目名称:Products.Silva,代码行数:14,代码来源:SilvaObject.py

示例7: store_activity

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def store_activity(document, event):
    if IObjectInitializedEvent.providedBy(event):
        return
    elif IContainerModifiedEvent.providedBy(event):
        return
    elif not ILayer.providedBy(getattr(document, 'REQUEST', None)):
        return
    elif not IUUIDAware.providedBy(document):
        return

    folder = document.aq_parent
    get_tool().store_activity(folder, 'modify', uid=IUUID(document))
开发者ID:collective,项目名称:collective.maildigest,代码行数:14,代码来源:modify.py

示例8: set_roles_after_modifying

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def set_roles_after_modifying(context, event):
    # Handle the modify event having been a removal of a related item
    setattr(
        context,
        'relatedItems',
        [item for item in getattr(context, 'relatedItems', []) if item.to_object],
    )

    if IContainerModifiedEvent.providedBy(event):
        return

    LocalRolesSetter(context).set_roles(event)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:14,代码来源:handlers.py

示例9: propagate_vocab_restrictions_to_children

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def propagate_vocab_restrictions_to_children(container, event):
    if ILocalrolesModifiedEvent.providedBy(event) or \
       IContainerModifiedEvent.providedBy(event):
        return

    restricted_fields = [
        ILifeCycle['retention_period'],
        ILifeCycle['archival_value'],
        ILifeCycle['custody_period']]

    propagate_vocab_restrictions(
        container, event, restricted_fields, ILifeCycleMarker)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:14,代码来源:lifecycle.py

示例10: disposition_modified

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def disposition_modified(context, event):
    if IContainerModifiedEvent.providedBy(event):
        return

    # Skip modified events during dossier destruction
    if IDuringDossierDestruction.providedBy(context.REQUEST):
        return

    storage = IHistoryStorage(context)
    storage.add('edited',
                api.user.get_current().getId(),
                context.get_dossier_representations())
开发者ID:4teamwork,项目名称:opengever.core,代码行数:14,代码来源:handlers.py

示例11: create_version_on_save

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def create_version_on_save(context, event):
    """Creates a new version on a versionable object when the object is saved.
    A new version is created if the type is automatic versionable and has
    changed or if the user has entered a change note.
    """
    # according to Products.CMFEditions' update_version_on_edit script

    # only version the modified object, not its container on modification
    if IContainerModifiedEvent.providedBy(event):
        return

    # XXX dirty hack for stagingbehavior, which triggers a event with
    # a aq_based context when deleting the working copy
    try:
        pr = context.portal_repository
    except AttributeError:
        return

    if not pr.isVersionable(context):
        # cancel, the object is not versionable
        return

    create_version = False

    if getattr(context, 'REQUEST', None):
        changeNote = get_change_note(context.REQUEST, None)
    else:
        changeNote = None

    if changeNote:
        # user has entered a change note. create a new version even if nothing
        # has changed.
        create_version = True

    elif pr.supportsPolicy(context, 'at_edit_autoversion'):
        # automatic versioning is enabled for this portal type

        if not base_hasattr(context, 'version_id'):
            # we do not have a initial version
            create_version = True
        else:
            try:
                create_version = not pr.isUpToDate(context, context.version_id)
            except ArchivistUnregisteredError:
                # The object is not actually registered, but a version is
                # set, perhaps it was imported, or versioning info was
                # inappropriately destroyed
                create_version = True

    # create new version if needed
    if create_version:
        pr.save(obj=context, comment=changeNote)
开发者ID:plone,项目名称:plone.app.versioningbehavior,代码行数:54,代码来源:subscribers.py

示例12: update_reference_prefixes

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def update_reference_prefixes(obj, event):
    """A eventhandler which reindex all contained objects, if the
    reference prefix has been changed.
    """
    if ILocalrolesModifiedEvent.providedBy(event) or \
       IContainerModifiedEvent.providedBy(event):
        return

    if is_reference_number_prefix_changed(event.descriptions):
        catalog = api.portal.get_tool('portal_catalog')
        children = catalog.unrestrictedSearchResults(
            path='/'.join(obj.getPhysicalPath()))
        for child in children:
            child.getObject().reindexObject(idxs=['reference'])
开发者ID:4teamwork,项目名称:opengever.core,代码行数:16,代码来源:subscribers.py

示例13: testCopyEvents

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
    def testCopyEvents(self):
        cp = self.reflecto.manage_copyObjects(('foo',))
        self.reflecto.manage_pasteObjects(cp)

        events = getEvents()
        self.assertEqual(len(events), 3)

        self.assertTrue(IObjectCopiedEvent.providedBy(events[0]))
        self.assertEqual(events[0].original.getId(), 'foo')
        self.assertEqual(events[0].object.getId(), 'copy_of_foo')

        self.assertTrue(IObjectClonedEvent.providedBy(events[1]))
        self.assertEqual(events[1].object.getId(), 'copy_of_foo')

        self.assertTrue(IContainerModifiedEvent.providedBy(events[2]))
        self.assertTrue(events[2].object is self.reflecto)
开发者ID:FHNW,项目名称:Products.Reflecto,代码行数:18,代码来源:testDirectory.py

示例14: update_favorites_title

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def update_favorites_title(context, event):
    """Event handler which updates the titles of all existing favorites for the
    current context, unless the title is personalized.
    """
    if IContainerModifiedEvent.providedBy(event):
        return

    if ILocalrolesModifiedEvent.providedBy(event):
        return

    if is_title_changed(event.descriptions):
        query = Favorite.query.filter(
            and_(Favorite.oguid == Oguid.for_object(context),
                 Favorite.is_title_personalized == False))  # noqa
        query.update_title(context.title)

        mark_changed(create_session())
开发者ID:4teamwork,项目名称:opengever.core,代码行数:19,代码来源:handlers.py

示例15: saveReferenceNumberPrefix

# 需要导入模块: from zope.container.interfaces import IContainerModifiedEvent [as 别名]
# 或者: from zope.container.interfaces.IContainerModifiedEvent import providedBy [as 别名]
def saveReferenceNumberPrefix(obj, event):
    """When an object providing IReferenceNumberPrefixMarker (repository
    folders) gets added or has been modified, make sure it has
    a unique reference number prefix.

    If necessary, set_number() creates a collision free prefix.
    """
    if IContainerModifiedEvent.providedBy(event):
        return

    parent = aq_parent(aq_inner(obj))

    # Mark the reference number as issued in the parent's annotations
    number = PrefixAdapter(parent).set_number(
        obj, IReferenceNumberPrefix(obj).reference_number_prefix)

    # Store the number on the actual object
    IReferenceNumberPrefix(obj).reference_number_prefix = number
开发者ID:4teamwork,项目名称:opengever.core,代码行数:20,代码来源:referenceprefix.py


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