[Zope3-checkins] CVS: Zope3/src/zope/app/container - zopecontainer.py:1.11

Sidnei da Silva sidnei@x3ng.com.br
Tue, 11 Feb 2003 14:54:06 -0500


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

Modified Files:
	zopecontainer.py 
Log Message:
Adding new tests to ZopeContainerAdapter rename method. Sorry for commiting broken tests

=== Zope3/src/zope/app/container/zopecontainer.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/container/zopecontainer.py:1.10	Tue Feb 11 13:04:16 2003
+++ Zope3/src/zope/app/container/zopecontainer.py	Tue Feb 11 14:53:36 2003
@@ -28,6 +28,7 @@
 from zope.app.interfaces.copy import IObjectMover
 from types import StringTypes
 from zope.proxy.introspection import removeAllProxies
+from zope.exceptions import NotFoundError, DuplicationError
 from zope.app.event.objectevent \
      import ObjectRemovedEvent, ObjectModifiedEvent, ObjectAddedEvent, \
             ObjectMovedEvent
@@ -172,10 +173,15 @@
         """
 
         object = self.get(currentKey)
+        if object is None:
+            raise NotFoundError(self.context, currentKey)
         mover = getAdapter(object, IObjectMover)
         container = self.context
         target = container
         
+        if target.__contains__(newKey):
+            raise DuplicationError("name, %s, is already in use" % newKey)
+
         if mover.moveable() and mover.moveableTo(target, newKey):
 
             # the mover will call manage_beforeDelete hook for us