[Zope3-checkins] CVS: Zope3/src/zope/app/container - configure.zcml:1.6.2.1 copy.py:1.1.2.6 zopecontainer.py:1.8.2.3

Sidnei da Silva sidnei@x3ng.com.br
Wed, 5 Feb 2003 05:09:47 -0500


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

Modified Files:
      Tag: paris-copypasterename-branch
	configure.zcml copy.py zopecontainer.py 
Log Message:
Fixing ObjectMover tests. Adding ObjectCopier tests. Adding AnnotatableUserClipboard with tests. That was a productive night :)

=== Zope3/src/zope/app/container/configure.zcml 1.6 => 1.6.2.1 ===
--- Zope3/src/zope/app/container/configure.zcml:1.6	Mon Feb  3 10:08:29 2003
+++ Zope3/src/zope/app/container/configure.zcml	Wed Feb  5 05:09:13 2003
@@ -64,7 +64,36 @@
            provides="zope.app.interfaces.size.ISized"
            for="zope.app.interfaces.container.IContainer" 
            />
+
+  <adapter 
+     provides="zope.app.interfaces.container.ICopySource"
+     for="zope.app.interfaces.container.IFolder"
+     permission="zope.ManageContent" 
+     factory="zope.app.container.copy.CopySource" 
+     />
+
+  <adapter 
+     provides="zope.app.interfaces.container.IMoveSource"
+     for="zope.app.interfaces.container.IFolder"
+     permission="zope.ManageContent" 
+     factory="zope.app.container.copy.MoveSource" 
+     />
+
+  <adapter 
+     provides="zope.app.interfaces.container.IPasteTarget"
+     for="zope.app.interfaces.container.IFolder"
+     permission="zope.ManageContent" 
+     factory="zope.app.container.copy.PasteTarget" 
+     />
            
+  <adapter 
+     provides="zope.app.interfaces.container.IPasteNamesChooser"
+     for="zope.app.interfaces.container.IFolder"
+     permission="zope.ManageContent" 
+     factory="zope.app.container.copy.PasteNamesChooser" 
+     />
+
+
   <event:subscribe 
       subscriber = ".dependency.CheckDependency"
       event_types = "zope.app.interfaces.event.IObjectRemovedEvent"


=== Zope3/src/zope/app/container/copy.py 1.1.2.5 => 1.1.2.6 ===
--- Zope3/src/zope/app/container/copy.py:1.1.2.5	Tue Feb  4 12:06:23 2003
+++ Zope3/src/zope/app/container/copy.py	Wed Feb  5 05:09:13 2003
@@ -17,7 +17,13 @@
 $Id$
 """
 
+from zope.app.interfaces.container import IOptionalNamesContainer
+from zope.app.interfaces.container import IContainerNamesContainer
+from zope.app.interfaces.container import IMoveSource
+from zope.app.interfaces.container import ICopySource
 from zope.app.interfaces.container import IPasteTarget
+from zope.app.interfaces.container import IPasteNamesChooser
+from zope.component import getAdapter
 from zope.proxy.introspection import removeAllProxies
 from zope.app.event.objectevent import ObjectModifiedEvent
 from zope.proxy.context import ContextWrapper
@@ -39,6 +45,8 @@
         this container. Otherwise, returns False.
         '''
         container = self.context
+        nameschooser = getAdapter(container, IPasteNamesChooser)
+        key = nameschooser.getNewName(obj, key)
         if key in container:
             return False
         return True
@@ -72,6 +80,9 @@
         # the container, because we can't store proxies.
         obj = removeAllProxies(obj)
 
+        nameschooser = getAdapter(container, IPasteNamesChooser)
+        key = nameschooser.getNewName(obj, key)
+
         # Add the object
         key = container.setObject(key, obj)
 
@@ -83,6 +94,8 @@
         
 class MoveSource:
 
+    __implements__ = IMoveSource
+
     def __init__(self, container):
         self.context = container
           
@@ -111,6 +124,8 @@
 
 class CopySource:
 
+    __implements__ = ICopySource
+
     def __init__(self, container):
         self.context = container
 
@@ -124,3 +139,26 @@
         if value is not None:
             return ContextWrapper(value, self.context, name=key)
         
+class PasteNamesChooser:
+
+    __implements__ = IPasteNamesChooser
+
+    def __init__(self, container):
+        self.context = container
+
+    def getNewName(self, obj, key):
+        '''See IPasteNamesChooser'''
+        new_key = key
+        container = self.context
+
+        if key not in container:
+            return key
+
+        n = 1 
+        while new_key in container:
+            if n > 1:
+                new_key = 'copy%s_of_%s' % (n, key)
+            else:
+                new_key = 'copy_of_%s' % key
+            n += 1
+        return new_key


=== Zope3/src/zope/app/container/zopecontainer.py 1.8.2.2 => 1.8.2.3 ===
--- Zope3/src/zope/app/container/zopecontainer.py:1.8.2.2	Tue Feb  4 11:02:16 2003
+++ Zope3/src/zope/app/container/zopecontainer.py	Wed Feb  5 05:09:13 2003
@@ -28,7 +28,6 @@
             ObjectMovedEvent
 from zope.app.interfaces.container import IAddNotifiable
 from zope.app.interfaces.container import IDeleteNotifiable
-from zope.app.interfaces.container import IContainerCopyPasteMoveSupport
 from zope.app.interfaces.copy import IObjectMover
 from types import StringTypes
 from zope.proxy.introspection import removeAllProxies
@@ -37,7 +36,7 @@
 
 class ZopeContainerAdapter:
 
-    __implements__ =  (IZopeContainer, IContainerCopyPasteMoveSupport)
+    __implements__ = IZopeContainer
 
     def __init__(self, container):
         self.context = container
@@ -186,8 +185,5 @@
 
             # the mover will call the manage_afterAdd hook for us
             # the mover will publish an ObjectMovedEvent for us
-
-
-