[CMF-checkins] CVS: CMF/CMFDefault - Link.py:1.13.2.4 utils.py:1.8.4.2
Andrew Sawyers
andrew@zope.com
Tue, 8 Jan 2002 16:05:01 -0500
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv23994/CMFDefault
Modified Files:
Tag: CMF-1_2-branch
Link.py utils.py
Log Message:
*Fixed utils.parseHeadersBody to properly handle windows and unix
newlines.
*Added full webdav code to support Link editing over webdav.
*Updated these changes in CHANGES.txt
=== CMF/CMFDefault/Link.py 1.13.2.3 => 1.13.2.4 ===
from Products.CMFCore import CMFCorePermissions
-from Products.CMFCore.PortalContent import PortalContent
+from Products.CMFCore.PortalContent import PortalContent, NoWL
+from Products.CMFCore.PortalContent import ResourceLockedError
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.CMFCore.utils import keywordsplitter
@@ -155,12 +156,10 @@
security.declarePrivate( '_writeFromPUT' )
def _writeFromPUT( self, body ):
-
headers = {}
headers, body = parseHeadersBody(body, headers)
lines = string.split( body, '\n' )
self.edit( lines[0] )
-
headers['Format'] = self.URL_FORMAT
new_subject = keywordsplitter(headers)
headers['Subject'] = new_subject or self.Subject()
@@ -169,7 +168,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'],
@@ -186,11 +185,18 @@
"""
Handle HTTP / WebDAV / FTP PUT requests.
"""
- self.dav__init(REQUEST, RESPONSE)
+ if not NoWL:
+ self.dav__init(REQUEST, RESPONSE)
+ self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
body = REQUEST.get('BODY', '')
- self._writeFromPUT( body )
- RESPONSE.setStatus(204)
- return RESPONSE
+ try:
+ self._writeFromPUT( body )
+ RESPONSE.setStatus(204)
+ return RESPONSE
+ except ResourceLockedError, msg:
+ get_transaction().abort()
+ RESPONSE.setStatus(423)
+ return RESPONSE
security.declareProtected( CMFCorePermissions.View, 'manage_FTPget' )
def manage_FTPget(self):
=== CMF/CMFDefault/utils.py 1.8.4.1 => 1.8.4.2 ===
-def parseHeadersBody( body, headers=None ):
+def parseHeadersBody( body, headers=None, rc=re.compile(r'\n|\r\n')):
"""
Parse any leading 'RFC-822'-ish headers from an uploaded
document, returning a dictionary containing the headers
@@ -61,7 +61,7 @@
Allow passing initial dictionary as headers.
"""
# Split the lines apart, taking into account Mac|Unix|Windows endings
- lines = re.split(r'[\n\r]+?', body)
+ lines = rc.split(body)
i = 0
if headers is None:
@@ -71,9 +71,7 @@
hdrlist = []
for line in lines:
- if line and line[-1] == '\r':
- line = line[:-1]
- if not line:
+ if not strip(line):
break
tokens = split( line, ': ' )
if len( tokens ) > 1: