[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/container - __init__.py:1.10

Sidnei da Silva sidnei@x3ng.com.br
Mon, 31 Mar 2003 09:48:42 -0500


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

Modified Files:
	__init__.py 
Log Message:
Refactored feature of getting a copy without children into separate adapters and interfaces. With tests :)

=== Zope3/src/zope/app/interfaces/container/__init__.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/interfaces/container/__init__.py:1.9	Sun Mar 30 10:41:00 2003
+++ Zope3/src/zope/app/interfaces/container/__init__.py	Mon Mar 31 09:48:41 2003
@@ -13,6 +13,29 @@
 class ContainerError(Exception):
     """An error of a container with one of its components."""
 
+class CopyException(Exception):
+    """An error that occurred within a copy operation."""
+
+    def __init__(self, container, key, message=""):
+        self.container = container
+        self.key = key
+        self.message = message and ": %s" % message
+
+    def __str__(self):
+        return ("%(key)s cannot be copied "
+                "from %(container)s%(message)s" % self.__dict__)
+
+class MoveException(Exception):
+    """An error that occurred within a move operation."""
+
+    def __init__(self, container, key, message=""):
+        self.container = container
+        self.key = key
+        self.message = message and ": %s" % message
+
+    def __str__(self):
+        return ("%(key)s cannot be copied "
+                "from %(container)s%(message)s" % self.__dict__)
 
 class UnaddableError(ContainerError):
     """An object cannot be added to a container."""
@@ -273,14 +296,22 @@
 
 class ICopySource(Interface):
     
-    def copyObject(key, copyingTo, with_children=True):
+    def copyObject(key, copyingTo):
         '''Return the object with the given key, as the first part of a
         copy.
 
         copyingTo is the unicode path for where the copy is to.
+        '''
+
+class INoChildrenCopySource(ICopySource):
+    
+    def copyObjectWithoutChildren(key, copyingTo):
+        '''Return the object with the given key, without any children,
+        as the first part of a copy.
+
+        copyingTo is the unicode path for where the copy is to.
 
-        If the object is a folder an with_children is True, then the folder
-        contents is copied too.
+        May return None if its not possible to get a copy without children.
         '''
 
 class IPasteNamesChooser(Interface):