[Zope3-checkins] CVS: Zope3/src/zope/app - copypastemove.py:1.4
Sidnei da Silva
sidnei@x3ng.com.br
Sun, 30 Mar 2003 10:41:27 -0500
Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv18283/src/zope/app
Modified Files:
copypastemove.py
Log Message:
Slight changes to IObjectCopier to allow copying without children. Its somewhat crufty, but I cant think of a better solution. Comes with tests :)
=== Zope3/src/zope/app/copypastemove.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/copypastemove.py:1.3 Wed Mar 19 14:57:21 2003
+++ Zope3/src/zope/app/copypastemove.py Sun Mar 30 10:40:57 2003
@@ -17,7 +17,7 @@
$Id$
"""
-from zope.app.traversing import getParent, objectName
+from zope.app.traversing import getParent, objectName, getPath
from zope.component import getAdapter, queryAdapter
from zope.app.interfaces.copypastemove import IObjectMover
from zope.app.interfaces.copypastemove import IObjectCopier
@@ -42,7 +42,7 @@
def __init__(self, object):
self.context = object
- def moveTo(self, target, name=None):
+ def moveTo(self, target, new_name=None):
'''Move this object to the target given.
Returns the new name within the target
@@ -51,15 +51,12 @@
obj = self.context
container = getParent(obj)
orig_name = objectName(obj)
- if name is None:
- name = objectName(obj)
+ if new_name is None:
+ new_name = orig_name
movesource = getAdapter(container, IMoveSource)
- physicaltarget = getAdapter(target, IPhysicallyLocatable)
- target_path = physicaltarget.getPath()
-
- physicalsource = getAdapter(container, IPhysicallyLocatable)
- source_path = physicalsource.getPath()
+ target_path = getPath(target)
+ source_path = getPath(container)
if queryAdapter(obj, IMoveNotifiable):
getAdapter(obj, IMoveNotifiable).beforeDeleteHook(obj, container, \
@@ -70,7 +67,7 @@
new_obj = movesource.removeObject(orig_name, target)
pastetarget = getAdapter(target, IPasteTarget)
# publish an ObjectCreatedEvent (perhaps...?)
- new_name = pastetarget.pasteObject(name,new_obj)
+ new_name = pastetarget.pasteObject(new_name, new_obj)
# call afterAddHook
if queryAdapter(new_obj, IMoveNotifiable):
@@ -107,7 +104,7 @@
def __init__(self, object):
self.context = object
- def copyTo(self, target, name=None):
+ def copyTo(self, target, new_name=None, with_children=True):
"""Copy this object to the target given.
Returns the new name within the target, or None
@@ -120,21 +117,19 @@
"""
obj = self.context
container = getParent(obj)
- if name is None:
- name = objectName(obj)
-
- physicaltarget = getAdapter(target, IPhysicallyLocatable)
- target_path = physicaltarget.getPath()
+ orig_name = objectName(obj)
+ if new_name is None:
+ new_name = orig_name
- physicalsource = getAdapter(container, IPhysicallyLocatable)
- source_path = physicalsource.getPath()
+ target_path = getPath(target)
+ source_path = getPath(container)
copysource = getAdapter(container, ICopySource)
- obj = copysource.copyObject(name, target_path)
+ obj = copysource.copyObject(orig_name, target_path, with_children)
pastetarget = getAdapter(target, IPasteTarget)
# publish an ObjectCreatedEvent (perhaps...?)
- new_name = pastetarget.pasteObject(name, obj)
+ new_name = pastetarget.pasteObject(new_name, obj)
# call afterAddHook
if queryAdapter(obj, ICopyNotifiable):