WebDAV MKCOL (was: [Zope-CMF] UnpickleableError)

seb bacon seb@jamkit.com
Fri, 25 May 2001 15:56:07 +0100


--LQksG6bCIzRHxTLp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Well, I did it anyway.  Patch attached if anyone's interested.

seb (your friendly friday bulk poster)

* seb bacon <seb@jamkit.com> [010525 12:46]:
> Thanks to everyone for the hints, you were all right.  Specifically, I
> was changing the File's title in manage_afterAdd like this:
> self.title=self.id; a schoolboy error :-)  I can't believe it took a
> whole day to track down...
> 
> Now I'm working on the fact that MKCOL doesn't work.  
> 
> Firstly, there's no provision in NullResource for MKCOL to create
> anything other than an OFS.Folder.  Since there's no way of
> differentiating between different *types* of folder, I figured a MKCOL
> factory wouldn't be of much use.  Instead, would it be a sensible
> policy always to create collection of the same type as the enclosing
> collection? 
> 
> Furthermore, because the current implementation assumes you're adding
> folders, it also assumes you need the 'Add Folder' permission, so the
> _verifyObjectPaste hack used in the NullResource PUT methods needs to
> be used too.
> 
> Would this be a reasonable approach?
> 
> seb

--LQksG6bCIzRHxTLp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="NullResource.patch"

*** /tmp/NullResource.py	Fri May 25 15:51:49 2001
--- /tmp/NullResource.py21178Y0T	Fri May 25 15:51:49 2001
***************
*** 21,27 ****
  
      __ac_permissions__=(
          ('View',                             ('HEAD',)),
-         ('Add Folders',                      ('MKCOL',)),
          ('WebDAV Lock items',                ('LOCK',)),
      )
  
--- 21,26 ----
***************
*** 106,111 ****
--- 105,111 ----
          RESPONSE.setBody('')
          return RESPONSE
  
+     MKCOL__roles__=('Anonymous',)
      def MKCOL(self, REQUEST, RESPONSE):
          """Create a new collection resource."""
          self.dav__init(REQUEST, RESPONSE)
***************
*** 130,136 ****
              # There was an If header, but the parent is not locked
              raise 'Precondition Failed'
  
!         parent.manage_addFolder(name)
          RESPONSE.setStatus(201)
          RESPONSE.setBody('')
          return RESPONSE
--- 130,146 ----
              # There was an If header, but the parent is not locked
              raise 'Precondition Failed'
  
!         ob = parent.__class__(name)
!         
! 	try:
!             parent._verifyObjectPaste(ob.__of__(parent), 0)
!         except 'Unauthorized':
!             raise 'Unauthorized', sys.exc_info()[1]
!         except:
!             raise 'Forbidden', sys.exc_info()[1]
! 
!         self.__parent__._setObject(name, ob)
! 
          RESPONSE.setStatus(201)
          RESPONSE.setBody('')
          return RESPONSE
***************
*** 354,359 ****
--- 364,370 ----
          RESPONSE.setBody('')
          return RESPONSE
  
+     MKCOL__roles__=('Anonymous',)
      def MKCOL(self, REQUEST, RESPONSE):
          """ Create a new Collection (folder) resource.  Since this is being
          done on a LockNull resource, this also involves removing the LockNull
***************
*** 387,393 ****
          locks = self.wl_lockItems()
          parent._delObject(name)
  
!         parent.manage_addFolder(name)
          folder = parent._getOb(name)
          for token, lock in locks:
              folder.wl_setLock(token, lock)
--- 398,414 ----
          locks = self.wl_lockItems()
          parent._delObject(name)
  
!         ob = parent.__class__(name)
!         
! 	try:
!             parent._verifyObjectPaste(ob.__of__(parent), 0)
!         except 'Unauthorized':
!             raise 'Unauthorized', sys.exc_info()[1]
!         except:
!             raise 'Forbidden', sys.exc_info()[1]
! 
!         self.__parent__._setObject(name, ob)
! 
          folder = parent._getOb(name)
          for token, lock in locks:
              folder.wl_setLock(token, lock)





--LQksG6bCIzRHxTLp--