Commit 080645b0 authored by Florent Guillaume's avatar Florent Guillaume

Merged 40370 from 2.9 branch:

Send ContainerModifiedEvent when appropriate.

This requires Five 1.3+ >= r20254.

Some BBB has been kept until Zope 3.2 >= r40368 is stiched in.
parent 929a4dc2
......@@ -37,6 +37,8 @@ from zope.interface import implements
from zope.event import notify
from zope.app.event.objectevent import ObjectCopiedEvent
from zope.app.container.contained import ObjectMovedEvent
import Products.Five # BBB: until Zope 3.2 >= r40368 is stiched in
from zope.app.container.contained import notifyContainerModified
from OFS.event import ObjectWillBeMovedEvent
from OFS.event import ObjectClonedEvent
import OFS.subscribers
......@@ -273,6 +275,9 @@ class CopyContainer(ExtensionClass.Base):
ob = self._getOb(id)
notify(ObjectMovedEvent(ob, orig_container, orig_id, self, id))
notifyContainerModified(orig_container)
if aq_base(orig_container) is not aq_base(self):
notifyContainerModified(self)
ob._postCopy(self, op=1)
# try to make ownership implicit if possible
......@@ -346,6 +351,7 @@ class CopyContainer(ExtensionClass.Base):
ob = self._getOb(new_id)
notify(ObjectMovedEvent(ob, self, id, self, new_id))
notifyContainerModified(self)
ob._postCopy(self, op=1)
......
......@@ -53,6 +53,8 @@ from Traversable import Traversable
from zope.event import notify
from zope.app.container.contained import ObjectAddedEvent
from zope.app.container.contained import ObjectRemovedEvent
import Products.Five # BBB: until Zope 3.2 >= r40368 is stiched in
from zope.app.container.contained import notifyContainerModified
from OFS.event import ObjectWillBeAddedEvent
from OFS.event import ObjectWillBeRemovedEvent
import OFS.subscribers
......@@ -312,6 +314,7 @@ class ObjectManager(
if not suppress_events:
notify(ObjectAddedEvent(ob, self, id))
notifyContainerModified(self)
OFS.subscribers.compatibilityCall('manage_afterAdd', ob, ob, self)
......@@ -360,6 +363,7 @@ class ObjectManager(
if not suppress_events:
notify(ObjectRemovedEvent(ob, self, id))
notifyContainerModified(self)
security.declareProtected(access_contents_information, 'objectIds')
def objectIds(self, spec=None):
......
......@@ -24,6 +24,8 @@ from Acquisition import aq_base
from DocumentTemplate.sequence import sort
from Globals import InitializeClass
from zope.interface import implements
import Products.Five # BBB: until Zope 3.2 >= r40368 is stiched in
from zope.app.container.contained import notifyContainerModified
from interfaces import IOrderedContainer as z3IOrderedContainer
from IOrderSupport import IOrderedContainer as z2IOrderedContainer
......@@ -135,7 +137,8 @@ class OrderSupport(object):
#
security.declareProtected(manage_properties, 'moveObjectsByDelta')
def moveObjectsByDelta(self, ids, delta, subset_ids=None):
def moveObjectsByDelta(self, ids, delta, subset_ids=None,
suppress_events=False):
""" Move specified sub-objects by delta.
"""
if type(ids) is StringType:
......@@ -180,6 +183,9 @@ class OrderSupport(object):
'not exist.' % subset_ids[pos])
self._objects = tuple(objects)
if not suppress_events:
notifyContainerModified(self)
return counter
security.declareProtected(manage_properties, 'moveObjectsUp')
......@@ -227,11 +233,12 @@ class OrderSupport(object):
raise ValueError('The object with the id "%s" does not exist.' % id)
security.declareProtected(manage_properties, 'moveObjectToPosition')
def moveObjectToPosition(self, id, position):
def moveObjectToPosition(self, id, position, suppress_events=False):
""" Move specified object to absolute position.
"""
delta = position - self.getObjectPosition(id)
return self.moveObjectsByDelta(id, delta)
return self.moveObjectsByDelta(id, delta,
suppress_events=suppress_events)
security.declareProtected(access_contents_information, 'getDefaultSorting')
def getDefaultSorting(self):
......@@ -257,7 +264,7 @@ class OrderSupport(object):
old_position = self.getObjectPosition(id)
result = super(OrderSupport, self).manage_renameObject(id, new_id,
REQUEST)
self.moveObjectToPosition(new_id, old_position)
self.moveObjectToPosition(new_id, old_position, suppress_events=True)
return result
def tpValues(self):
......
......@@ -40,6 +40,7 @@ from Products.ZCatalog.Lazy import LazyMap
from zope.event import notify
from zope.app.container.contained import ObjectAddedEvent
from zope.app.container.contained import ObjectRemovedEvent
from zope.app.container.contained import notifyContainerModified
from OFS.event import ObjectWillBeAddedEvent
from OFS.event import ObjectWillBeRemovedEvent
import OFS.subscribers
......@@ -443,6 +444,7 @@ class BTreeFolder2Base (Persistent):
if not suppress_events:
notify(ObjectAddedEvent(ob, self, id))
notifyContainerModified(self)
OFS.subscribers.compatibilityCall('manage_afterAdd', ob, ob, self)
......@@ -461,6 +463,7 @@ class BTreeFolder2Base (Persistent):
if not suppress_events:
notify(ObjectRemovedEvent(ob, self, id))
notifyContainerModified(self)
# Aliases for mapping-like access.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment