[CMF-checkins] CVS: Products/CMFCore - PortalFolder.py:1.25

Tres Seaver tseaver@zope.com
Mon, 3 Dec 2001 16:33:39 -0500


Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv15464/CMFCore

Modified Files:
	PortalFolder.py 
Log Message:


  - Make FTP's MKDIR and WebDAV's MKCOL work by intercepting
    'manage_addFolder' per Jeffrey's dogbowl proposal,
     http://cmf.zope.org/PTK/Members/jshell/FolderCreationProposal.txt
    Tracker #183.


=== Products/CMFCore/PortalFolder.py 1.24 => 1.25 ===
         self.title = title
 
+    security.declareProtected( CMFCorePermissions.ManageProperties
+                             , 'setTitle')
+    def setTitle( self, title ):
+        """
+            Edit the folder title.
+        """
+        self.title = title
+
+    security.declareProtected( CMFCorePermissions.ManageProperties
+                             , 'setDescription')
+    def setDescription( self, description ):
+        """
+            Edit the folder description.
+        """
+        self.description = description
+
     security.declareProtected(CMFCorePermissions.ManageProperties, 'edit')
     def edit(self, title='', description=''):
         """
         Edit the folder title (and possibly other attributes later)
         """
-        self.title = title
-        self.description = description
+        self.setTitle( title )
+        self.setDescription( description )
 
     security.declarePublic('allowedContentTypes')
     def allowedContentTypes( self ):
@@ -319,11 +335,7 @@
         """
             Handle WebDAV MKCOL.
         """
-        type_name = self._getPortalTypeName()
-        self.invokeFactory( type_name=type_name
-                          , id=id
-                          , RESPONSE=RESPONSE
-                          )
+        self.manage_addFolder( id=id, title='' )
 
     def _checkId(self, id, allow_dup=0):
         PortalFolder.inheritedAttribute('_checkId')(self, id, allow_dup)
@@ -405,6 +417,38 @@
 
     security.setPermissionDefault(AddPortalContent, ('Owner','Manager'))
     security.setPermissionDefault(AddPortalFolders, ('Owner','Manager'))
+
+    def manage_addFolder( self
+                        , id
+                        , title=''
+                        , REQUEST=None
+                        ):
+        """
+            Add a new folder-like object with id *id*.  IF present,
+            use the parent object's 'mkdir' action;  otherwise, just
+            add a PortalFolder.
+            to take control of the process by checking for a 'mkdir'
+            action.
+        """
+        try:
+            action = self.getTypeInfo().getActionById( 'mkdir' )
+        except TypeError:
+            self.invokeFactory( type_name='Folder', id=id )
+        else:
+            # call it
+            getattr( self, action )( id=id )
+
+        ob = self._getOb( id )
+        ob.setTitle( title )
+        try:
+            ob.reindexObject()
+        except AttributeError:
+            pass
+
+        if REQUEST is not None:
+            return self.manage_main(self, REQUEST, update_menu=1)
+
+Globals.InitializeClass(PortalFolder)
     
 
 
@@ -506,8 +550,6 @@
             Return a stringified description of the filter.
         """
         return string.join( self.description, '; ' )
-
-Globals.InitializeClass(PortalFolder)
 
 manage_addPortalFolder = PortalFolder.manage_addPortalFolder
 manage_addPortalFolderForm = DTMLFile( 'folderAdd', globals() )