[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container - DependencyChecker.py:1.2.2.1 IContainer.py:1.6.2.1 ZopeContainerAdapter.py:1.2.2.1

Jim Fulton jim@zope.com
Sat, 30 Nov 2002 07:44:56 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container
In directory cvs.zope.org:/tmp/cvs-serv30047/lib/python/Zope/App/OFS/Container

Modified Files:
      Tag: Zope3-Bangalore-TTW-Branch
	DependencyChecker.py IContainer.py ZopeContainerAdapter.py 
Log Message:
Refactored the way TTW component registration is done.  There are now
separate registry objects that abstract the machinery for registering
multiple conflicting configurations and deciding which, if any are
active.  Also provided a new field and widget for the status
information.

Along the way, cleaned up and streamlined placeful testing
infrastructure a bit.

Now checking into branch. Will give file-by-file (or at least more
specific logs) when the changes are merged into the head.


=== Zope3/lib/python/Zope/App/OFS/Container/DependencyChecker.py 1.2 => 1.2.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Container/DependencyChecker.py:1.2	Mon Nov 18 18:47:58 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/DependencyChecker.py	Sat Nov 30 07:44:25 2002
@@ -17,9 +17,10 @@
 """
 from Zope.ComponentArchitecture import queryAdapter
 from Zope.App.DependencyFramework.IDependable import IDependable
-from Zope.App.DependencyFramework.Exception import DependencyError
+from Zope.App.DependencyFramework.Exceptions import DependencyError
 from Zope.Event.ISubscriber import ISubscriber
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
 class DependencyChecker:
     """Checking dependency  while deleting object
     """
@@ -34,9 +35,7 @@
         if dependency is not None:
             if dependency.dependents():
                 raise DependencyError(" Removal of object dependable")
-            
-
-    
+                
 CheckDependency = DependencyChecker() 
     
         


=== Zope3/lib/python/Zope/App/OFS/Container/IContainer.py 1.6 => 1.6.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Container/IContainer.py:1.6	Mon Nov 18 08:34:19 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/IContainer.py	Sat Nov 30 07:44:25 2002
@@ -11,8 +11,9 @@
 # FOR A PARTICULAR PURPOSE.
 # 
 ##############################################################################
-"""
+"""Container interfaces
 
+$Id$
 """
 
 
@@ -57,6 +58,15 @@
 
 class IContainer(IReadContainer, IWriteContainer):
     """Readable and writable content container."""
+
+
+class IOptionalNamesContainer(IContainer):
+    """Containers that will choose names for their items if no names are given
+    """
+
+class IContainerNamesContainer(IContainer):
+    """Containers that always choose names for their items
+    """
 
 class IHomogenousContainer(Interface):
 


=== Zope3/lib/python/Zope/App/OFS/Container/ZopeContainerAdapter.py 1.2 => 1.2.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Container/ZopeContainerAdapter.py:1.2	Mon Nov 18 18:52:58 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/ZopeContainerAdapter.py	Sat Nov 30 07:44:25 2002
@@ -18,6 +18,8 @@
 """
 
 from Zope.App.OFS.Container.IZopeContainer import IZopeContainer
+from Zope.App.OFS.Container.IContainer import IOptionalNamesContainer
+from Zope.App.OFS.Container.IContainer import IContainerNamesContainer
 from Zope.ComponentArchitecture import queryAdapter
 from Zope.Proxy.ContextWrapper import ContextWrapper
 from Zope.Event import publishEvent
@@ -82,16 +84,22 @@
 
     def setObject(self, key, object):
         "See Zope.App.OFS.Container.IZopeContainer.IZopeWriteContainer"
-        
-        if type(key) in StringTypes and len(key)==0:
-            raise ValueError("The id cannot be an empty string")
+
+        if not isinstance(key, StringTypes):
+            raise TypeError("Item name is not a string.")
+
+        container = self.context
+
+        if not key:
+            if not (IOptionalNamesContainer.isImplementedBy(container)
+                    or IContainerNamesContainer.isImplementedBy(container)):
+                raise ValueError("Empty names are not allowed")
 
         # We remove the proxies from the object before adding it to
         # the container, because we can't store proxies.
         object = removeAllProxies(object)
 
         # Add the object
-        container = self.context
         key = container.setObject(key, object)
 
         # Publish an added event