[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Folder - Folder.py:1.1.4.4 LoadedFolder.py:1.1.4.3

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


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

Modified Files:
      Tag: Zope-3x-branch
	Folder.py LoadedFolder.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/Content/Folder/Folder.py 1.1.4.3 => 1.1.4.4 ===
         if type(name) in StringTypes and len(name)==0:
             raise ValueError
-        if not self.isAddable(getattr(object,'__implements__', None)):
-            raise UnaddableError (self, object, name)
         self.data[name] = object
 
     def delObject(self, name):
         """Delete the named object from the folder. Raises a KeyError
            if the object is not found."""
         del self.data[name]
-
-    def isAddable(self, interfaces):
-        return 1
 


=== Zope3/lib/python/Zope/App/OFS/Content/Folder/LoadedFolder.py 1.1.4.2 => 1.1.4.3 ===
 
 - Define what content objects can be added (user)
-  (* notice isAddable; adding an interfaces service could make
-  this functionality more usable TTW)
   + add the option to the configuration zpt
   + how does the security work for this? like if this folder is
     created under a folder that doesnt allow images for example?
@@ -41,26 +39,9 @@
 
 from Zope.App.OFS.Container.Exceptions import UnaddableError
 
-
-def membership_check(group, item): # use later for more interesting isAddable implementations
-    if type(group) is tuple:
-        for inter in group:
-            if membership_check(inter, item):
-                return 1
-        return 0
-    if type(item) is tuple:
-        for inter in item:
-            if membership_check(group, inter):
-                return 1
-        return 0
-    return group is item or issubclass(item, group)
-
-
 class ILoadedFolder(IFolder):
     """The standard Zope Loaded Folder object interface."""
 
-
-
 class LoadedFolder(Folder, FolderLimit, OrderedFolder):
     """Implements some nice additional features to the regular
        Folder.
@@ -107,8 +88,6 @@
         """Add the given object to the folder under the given name."""
         if type(name) in StringTypes and len(name)==0:
             raise ValueError
-        if not self.isAddable(getattr(object,'__implements__', None)):
-            raise UnaddableError (self, object, name)
         if self.isLimitReached():
             raise FolderLimitExceededError(self, object,
                        'The folder\'s limit (%d item%s) was exeeded.' %
@@ -126,6 +105,3 @@
         ids = list(self._orderedIds)
         ids.remove(name)
         self._orderedIds = tuple(ids)
-
-    def isAddable(self, interfaces):
-        return 1 # could return 0 if self.isLimitReached(), and eliminate check above...