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

Chris McDonough chrism@zope.com
Mon, 23 Jun 2003 18:40:49 -0400


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

Modified Files:
	zopecontainer.py 
Log Message:
Allow empty names if our container type doesn't care.


=== Zope3/src/zope/app/container/zopecontainer.py 1.23 => 1.24 ===
--- Zope3/src/zope/app/container/zopecontainer.py:1.23	Sun Jun 15 12:38:29 2003
+++ Zope3/src/zope/app/container/zopecontainer.py	Mon Jun 23 18:40:48 2003
@@ -112,16 +112,17 @@
 
     def setObject(self, key, object):
         "See IZopeWriteContainer"
-        if not isinstance(key, StringTypes):
-            raise TypeError("Item name is not a string.")
-
         container = getProxiedObject(self)
 
         if not key:
             if not (IOptionalNamesContainer.isImplementedBy(container)
                     or IContainerNamesContainer.isImplementedBy(container)):
                 raise ValueError("Empty names are not allowed")
-
+            key = ''
+        else:
+            if not isinstance(key, StringTypes):
+                raise TypeError("Item name is not a string.")
+            
         # We remove the proxies from the object before adding it to
         # the container, because we can't store proxies.
         object = removeAllProxies(object)