yuppie wrote:
PortalFolder is not just a base class, it's *the* folder class used in CMFDefault. Subclasses can mix in OrderSupport, but that has no effect on PortalFolder instances.

Oh you are right. I had in mind that all content types are declared in CMFDefault. In this case I have to retract my proposal.

That's not fair. You are free to ignore CMF development for years, but you can't make other people pay for that. Upgrading from 1.5.x to the latest 1.5 version has to work without *any* trouble.

I'm sorry but I'm a little bit nervous. I have to get Plone 2.1 up and running on CMF 1.5 until saturday or Plone 2.1 will stay on CMF 1.4.

manage_renameObject is the only method that overrides Folder behavior. Defunct IOrderedContainer methods should not be a big problem. After all we are still in Zope 2 land with tons of inherited useless methods.


I'm open for any proposal that adds a *new* base class for CMF folders.

I have another idea. The patch is attached to this mail. In short terms I have renamed PortalFolder to PortalFolderBase subclassed of Folder and created a new PortalFolder class subclassed from OrderedFolder. PortalFolderBase contains nearly all code from PortalFolder. This way it is easy to subclass from PortalFolderBase w/o ordered support.

class PortalFolderBase(DynamicType, CMFCatalogAware, Folder):

class PortalFolder(PortalFolderBase, OrderedFolder):
    manage_renameObject = OrderedFolder.manage_renameObject.im_func
    tpValues = OrderedFolder.tpValues.im_func


All tests are running fine.

Christian
Index: CMFCore/PortalFolder.py
===================================================================
RCS file: /cvs-repository/Products/CMFCore/PortalFolder.py,v
retrieving revision 1.71.2.8
diff -u -r1.71.2.8 PortalFolder.py
--- CMFCore/PortalFolder.py     14 Jun 2005 16:39:33 -0000      1.71.2.8
+++ CMFCore/PortalFolder.py     20 Jun 2005 17:10:54 -0000
@@ -26,6 +26,7 @@
 from Globals import DTMLFile
 from Globals import InitializeClass
 from OFS.OrderedFolder import OrderedFolder
+from OFS.Folder import Folder
 
 from CMFCatalogAware import CMFCatalogAware
 from DynamicType import DynamicType
@@ -96,22 +97,19 @@
 )
 
 
-class PortalFolder(DynamicType, CMFCatalogAware, OrderedFolder):
+class PortalFolderBase(DynamicType, CMFCatalogAware, Folder):
+    """Base class for portal folder
     """
-        Implements portal content management, but not UI details.
-    """
-    meta_type = 'Portal Folder'
-    portal_type = 'Folder'
+    meta_type = 'Portal Folder Base'
 
-    __implements__ = (IFolderish, DynamicType.__implements__,
-                      OrderedFolder.__implements__)
+    __implements__ = (IFolderish, DynamicType.__implements__, 
Folder.__implements__)
 
     security = ClassSecurityInfo()
 
     description = ''
-
-    manage_options = ( OrderedFolder.manage_options +
-                       CMFCatalogAware.manage_options )
+    
+    manage_options = ( Folder.manage_options +
+                       CMFCatalogAware.manage_options )  
 
     def __init__( self, id, title='' ):
         self.id = id
@@ -165,15 +163,6 @@
                           typ.isConstructionAllowed( container )
                      , result )
 
-    security.declareProtected(AddPortalFolders, 'manage_addPortalFolder')
-    def manage_addPortalFolder(self, id, title='', REQUEST=None):
-        """Add a new PortalFolder object with id *id*.
-        """
-        ob = PortalFolder(id, title)
-        self._setObject(id, ob)
-        if REQUEST is not None:
-            return self.folder_contents( # XXX: ick!
-                self, REQUEST, portal_status_message="Folder added")
 
     def _morphSpec(self, spec):
         '''
@@ -433,7 +422,7 @@
         self.manage_addFolder( id=id, title='' )
 
     def _checkId(self, id, allow_dup=0):
-        PortalFolder.inheritedAttribute('_checkId')(self, id, allow_dup)
+        PortalFolderBase.inheritedAttribute('_checkId')(self, id, allow_dup)
 
         if allow_dup:
             return
@@ -533,7 +522,7 @@
 
         # Call OFS' _verifyObjectPaste if necessary
         if not securityChecksDone:
-            PortalFolder.inheritedAttribute(
+            PortalFolderBase.inheritedAttribute(
                 '_verifyObjectPaste')(self, object, validate_src)
 
         # Finally, check allowed content types
@@ -551,7 +540,6 @@
                                         % type_name)
 
     security.setPermissionDefault(AddPortalContent, ('Owner','Manager'))
-    security.setPermissionDefault(AddPortalFolders, ('Owner','Manager'))
 
     security.declareProtected(AddPortalFolders, 'manage_addFolder')
     def manage_addFolder( self
@@ -581,6 +569,37 @@
 
         if REQUEST is not None:
             return self.manage_main(self, REQUEST, update_menu=1)
+
+InitializeClass(PortalFolderBase)
+
+
+class PortalFolder(PortalFolderBase, OrderedFolder):
+    """
+        Implements portal content management, but not UI details.
+    """
+    meta_type = 'Portal Folder'
+    portal_type = 'Folder'
+
+    __implements__ = (PortalFolderBase.__implements__,
+                      OrderedFolder.__implements__)
+
+    security = ClassSecurityInfo()
+
+    manage_options = ( OrderedFolder.manage_options +
+                       CMFCatalogAware.manage_options )
+
+    security.declareProtected(AddPortalFolders, 'manage_addPortalFolder')
+    def manage_addPortalFolder(self, id, title='', REQUEST=None):
+        """Add a new PortalFolder object with id *id*.
+        """
+        ob = PortalFolder(id, title)
+        self._setObject(id, ob)
+        if REQUEST is not None:
+            return self.folder_contents( # XXX: ick!
+                self, REQUEST, portal_status_message="Folder added")
+                
+    manage_renameObject = OrderedFolder.manage_renameObject.im_func
+    tpValues = OrderedFolder.tpValues.im_func
 
 InitializeClass(PortalFolder)
 
_______________________________________________
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to