[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/AddableService - GlobalAddableService.py:1.1.2.3

Jim Fulton jim@zope.com
Sat, 8 Jun 2002 13:15:26 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/AddableService
In directory cvs.zope.org:/tmp/cvs-serv32437/lib/python/Zope/App/OFS/Services/AddableService

Modified Files:
      Tag: Zope-3x-branch
	GlobalAddableService.py 
Log Message:
Refactored isAddable method out of IContainer into a separate, more
specilized interface. This part of the framework needs more thought,
but, in any case, containers that don't need to restrict their content
(or that restrict it in other ways) shouldn't be burdened by this part
of the interface.

I also rewrote IContainer doc strings to conform to coding style.


=== Zope3/lib/python/Zope/App/OFS/Services/AddableService/GlobalAddableService.py 1.1.2.2 => 1.1.2.3 ===
 from Addable import Addable
 from Zope.App.OFS.Container.IContainer import IWriteContainer
+from Zope.App.OFS.Container.IContainer import IHomogenousContainer
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
 
 class IGlobalAddableService(IAddableService):
@@ -57,19 +58,23 @@
                                   for_container=for_container, 
                                   creation_markers=creation_markers))
 
-    def getAddables(self, ob):
+    def getAddables(self, ob, allowed_types=None):
         clean_object=removeAllProxies(ob)
         addables=[]
         for addable in self.__reg:
             for_c=addable.for_container
             if not for_c or multi_implement_check(for_c, clean_object):
+
                 try:
                     inter=getFactoryInterfaces(ob, addable.id)
                 except ComponentLookupError:
                     continue
-                if IWriteContainer.isImplementedBy(clean_object) and not \
-                   ob.isAddable(inter):
+                if (IHomogenousContainer.isImplementedBy(clean_object)
+                    and not
+                    ob.isAddable(inter)
+                    ):
                     continue
+
                 addables.append(addable)
         return addables
     
@@ -90,4 +95,4 @@
 # Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
 from Zope.Testing.CleanUp import addCleanUp
 addCleanUp(_clear)
-del addCleanUp
\ No newline at end of file
+del addCleanUp