[Zope3-checkins] CVS: Zope3/src/zope/app - copy.py:1.2.2.4
Sidnei da Silva
sidnei@x3ng.com.br
Tue, 4 Feb 2003 12:06:54 -0500
Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv22890/src/zope/app
Modified Files:
Tag: paris-copypasterename-branch
copy.py
Log Message:
Fourth stab at getting tests right. We are a little closer now.
=== Zope3/src/zope/app/copy.py 1.2.2.3 => 1.2.2.4 ===
--- Zope3/src/zope/app/copy.py:1.2.2.3 Tue Feb 4 11:02:14 2003
+++ Zope3/src/zope/app/copy.py Tue Feb 4 12:06:22 2003
@@ -18,7 +18,7 @@
"""
from zope.app.traversing import getParent, objectName
-from zope.component import getAdapter
+from zope.component import getAdapter, queryAdapter
from zope.app.interfaces.copy import IObjectMover
from zope.app.interfaces.copy import IObjectCopier
from zope.app.interfaces.container import IAddNotifiable
@@ -28,6 +28,8 @@
from zope.app.interfaces.container import IMoveSource
from zope.app.interfaces.container import IPasteTarget
from zope.app.interfaces.traversing import IPhysicallyLocatable
+from zope.app.event.objectevent import ObjectMovedEvent
+from zope.app.event import publish
class ObjectMover:
'''Use getAdapter(obj, IObjectMover) to move an object somewhere.'''
@@ -45,6 +47,7 @@
obj = self.context
container = getParent(obj)
+ orig_name = objectName(obj)
if name is None:
name = objectName(obj)
@@ -61,17 +64,17 @@
elif queryAdapter(obj, IDeleteNotifiable):
getAdapter(obj, IDeleteNotifiable).manage_beforeDelete(obj, container)
- obj = movesource.removeObject(name, target)
+ new_obj = movesource.removeObject(orig_name, target)
pastetarget = getAdapter(target, IPasteTarget)
# publish an ObjectCreatedEvent (perhaps...?)
new_name = pastetarget.pasteObject(name, new_obj)
# call manage_afterAdd hook
- if queryAdapter(obj, IMoveNotifiable):
- getAdapter(obj, IMoveNotifiable).manage_afterAdd(obj, container, \
+ if queryAdapter(new_obj, IMoveNotifiable):
+ getAdapter(new_obj, IMoveNotifiable).manage_afterAdd(new_obj, container, \
movedFrom=source_path)
- elif queryAdapter(obj, IAddNotifiable):
- getAdapter(obj, IAddNotifiable).manage_afterAdd(obj, container)
+ elif queryAdapter(new_obj, IAddNotifiable):
+ getAdapter(new_obj, IAddNotifiable).manage_afterAdd(new_obj, container)
# publish ObjectMovedEvent
publish(container, ObjectMovedEvent(container))
@@ -128,7 +131,7 @@
pastetarget = getAdapter(target, IPasteTarget)
# publish an ObjectCreatedEvent (perhaps...?)
- new_name = pastetarget.pasteObject(name, new_obj)
+ new_name = pastetarget.pasteObject(name, obj)
# call manage_afterAdd hook
if queryAdapter(obj, ICopyNotifiable):