[Zope3-checkins] CVS: Zope3/src/zope/app/container - copypastemove.py:1.4

Sidnei da Silva sidnei@x3ng.com.br
Sun, 30 Mar 2003 10:41:29 -0500


Update of /cvs-repository/Zope3/src/zope/app/container
In directory cvs.zope.org:/tmp/cvs-serv18283/src/zope/app/container

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/container/copypastemove.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/container/copypastemove.py:1.3	Thu Mar 13 13:49:05 2003
+++ Zope3/src/zope/app/container/copypastemove.py	Sun Mar 30 10:40:58 2003
@@ -23,6 +23,7 @@
 from zope.app.interfaces.container import ICopySource
 from zope.app.interfaces.container import IPasteTarget
 from zope.app.interfaces.container import IPasteNamesChooser
+from zope.app.interfaces.content.folder import ICloneWithoutChildren
 from zope.component import getAdapter
 from zope.proxy.introspection import removeAllProxies
 from zope.app.event.objectevent import ObjectModifiedEvent
@@ -131,7 +132,7 @@
     def __init__(self, container):
         self.context = container
 
-    def copyObject(self, key, copyingTo):
+    def copyObject(self, key, copyingTo, with_children=True):
         '''Return the object with the given key, as the first part of a
         copy.
 
@@ -140,7 +141,13 @@
         value = self.context.get(key, None)
         if value is not None:
             value = removeAllProxies(value)
-            value = copy.deepcopy(value)
+            if with_children:
+                value = copy.deepcopy(value)
+            else:
+                if ICloneWithoutChildren.isImplementedBy(value):
+                    value = value.cloneWithoutChildren()
+                else:
+                    raise NotImplementedError(value, ICloneWithoutChildren)
             return ContextWrapper(value, self.context, name=key)
 
 class PasteNamesChooser: