[CMF-checkins] CVS: CMF/CMFDefault - Document.py:1.31 DublinCore.py:1.13
Andrew Sawyers
andrew@zope.com
Mon, 26 Nov 2001 14:00:19 -0500
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv25607/CMFDefault
Modified Files:
Document.py DublinCore.py
Log Message:
*Fixed support for webDAV locking on Document. Added edit method
to handle TTW edits, while PUT calls _edit.
*Added editMetadata method for TTW edits to handle checks and
ensure TTW can't edit the metadata of a webDAV locked document.
*Made necessary skin changes to implement these new methods.
*Added failIfLocked method to PortalContent to handle the TTW
checks if a document has a webDAV lock.
=== CMF/CMFDefault/Document.py 1.30 => 1.31 ===
from Products.CMFCore.PortalContent import PortalContent
from DublinCore import DefaultDublinCoreImpl
-
+from webdav.Lockable import ResourceLockedError
from Products.CMFCore import CMFCorePermissions
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.CMFCore.utils import _format_stx, keywordsplitter
@@ -183,7 +183,7 @@
security.declareProtected(CMFCorePermissions.ModifyPortalContent,
'manage_editDocument' )
- def manage_editDocument(self, text_format, text, file='', REQUEST=None):
+ def manage_editDocument(self, text, file='', REQUEST=None):
""" A ZMI (Zope Management Interface) level editing method """
self._edit(text_format, text, file)
if REQUEST is not None:
@@ -226,7 +226,7 @@
if key != 'Format' and not haveheader(key):
headers[key] = value
- self.editMetadata(title=headers['Title'],
+ self._editMetadata(title=headers['Title'],
subject=headers['Subject'],
description=headers['Description'],
contributors=headers['Contributors'],
@@ -238,7 +238,14 @@
)
security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'edit' )
- edit = WorkflowAction(_edit)
+ def edit(self, text_format, text, file='', safety_belt=''):
+ """
+ *used to be WorkflowAction(_edit)
+ To add webDav support, we need to check if the content is locked, and if
+ so return ResourceLockedError if not, call _edit.
+ """
+ self.failIfLocked()
+ self._edit(text_format, text, file='', safety_belt='')
security.declarePrivate('guessFormat')
def guessFormat(self, text):
@@ -391,9 +398,11 @@
## FTP handlers
security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'PUT')
+
def PUT(self, REQUEST, RESPONSE):
""" Handle HTTP (and presumably FTP?) PUT requests """
self.dav__init(REQUEST, RESPONSE)
+ self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
body = REQUEST.get('BODY', '')
guessedformat = REQUEST.get_header('Content-Type', 'text/plain')
ishtml = (guessedformat == 'text/html') or utils.html_headcheck(body)
@@ -402,13 +411,17 @@
else: self.setFormat('text/plain')
try:
- self.edit(text_format=self.text_format, text=body)
+ self._edit(text_format=self.text_format, text=body)
except 'EditingConflict', msg:
# XXX Can we get an error msg through? Should we be raising an
# exception, to be handled in the FTP mechanism? Inquiring
# minds...
get_transaction().abort()
RESPONSE.setStatus(450)
+ return RESPONSE
+ except ResourceLockedError, msg:
+ get_transaction().abort()
+ RESPONSE.setStatus(423)
return RESPONSE
RESPONSE.setStatus(204)
=== CMF/CMFDefault/DublinCore.py 1.12 => 1.13 ===
security.declareProtected( CMFCorePermissions.ModifyPortalContent
, 'editMetadata' )
- editMetadata = WorkflowAction(_editMetadata)
-
-
+ def editMetadata(self
+ , title=''
+ , subject=()
+ , description=''
+ , contributors=()
+ , effective_date=None
+ , expiration_date=None
+ , format='text/html'
+ , language='en-US'
+ , rights=''
+ ):
+ """
+ used to be: editMetadata = WorkflowAction(_editMetadata)
+ Need to add check for webDAV locked resource for TTW methods.
+ """
+ self.failIfLocked()
+ self._editMetadata(title=title
+ , subject=subject
+ , description=description
+ , contributors=contributors
+ , effective_date=effective_date
+ , expiration_date=expiration_date
+ , format=format
+ , language=language
+ , rights=rights
+ )
InitializeClass(DefaultDublinCoreImpl)