Commit ce4c64ac authored by Florent Guillaume's avatar Florent Guillaume

Merged Five 1.2 branch changeset 20253:

Send ContainerModifiedEvent when appropriate.

This requires Five 1.3+ >= r20254.

Some BBB has been kept until Zope 3.2 >= r40368 is stiched in.
parent 8f3efd0a
......@@ -33,6 +33,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
......@@ -272,6 +274,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
......@@ -342,6 +347,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)
......
......@@ -46,6 +46,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
......@@ -313,6 +315,7 @@ class ObjectManager(
if not suppress_events:
notify(ObjectAddedEvent(ob, self, id))
notifyContainerModified(self)
OFS.subscribers.compatibilityCall('manage_afterAdd', ob, ob, self)
......@@ -361,6 +364,7 @@ class ObjectManager(
if not suppress_events:
notify(ObjectRemovedEvent(ob, self, id))
notifyContainerModified(self)
def objectIds(self, spec=None):
# Returns a list of subobject ids of the current object.
......
......@@ -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