[CMF-checkins] CVS: CMF/CMFDefault - Document.py:1.42 Link.py:1.16 utils.py:1.10
Andrew Sawyers
andrew@zope.com
Thu, 10 Jan 2002 11:26:53 -0500
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv5016/CMFDefault
Modified Files:
Document.py Link.py utils.py
Log Message:
*Merging bugfixes from 1_2-branch into head.
=== CMF/CMFDefault/Document.py 1.41 => 1.42 ===
from Globals import DTMLFile, InitializeClass
from AccessControl import ClassSecurityInfo, getSecurityManager
+
from Products.CMFCore.PortalContent import PortalContent
-from DublinCore import DefaultDublinCoreImpl
-from webdav.Lockable import ResourceLockedError
+from Products.CMFCore.PortalContent import NoWL, ResourceLockedError
from Products.CMFCore import CMFCorePermissions
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.CMFCore.utils import _format_stx, keywordsplitter
@@ -341,8 +341,9 @@
def PUT(self, REQUEST, RESPONSE):
""" Handle HTTP (and presumably FTP?) PUT requests """
- self.dav__init(REQUEST, RESPONSE)
- self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
+ if not NoWL:
+ 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)
=== CMF/CMFDefault/Link.py 1.15 => 1.16 ===
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
@@ -105,6 +106,24 @@
self.title=title
self.remote_url=remote_url
self.description=description
+ self.format=self.URL_FORMAT
+
+ security.declareProtected( CMFCorePermissions.ModifyPortalContent
+ , 'manage_edit' )
+ manage_edit = DTMLFile( 'zmi_editLink', _dtmldir )
+
+ security.declareProtected( CMFCorePermissions.ModifyPortalContent
+ , 'manage_editLink' )
+ def manage_editLink( self, remote_url, REQUEST=None ):
+ """
+ Update the Link via the ZMI.
+ """
+ self._edit( remote_url )
+ if REQUEST is not None:
+ REQUEST['RESPONSE'].redirect( self.absolute_url()
+ + '/manage_edit'
+ + '?manage_tabs_message=Link+updated'
+ )
security.declareProtected( CMFCorePermissions.ModifyPortalContent
, 'manage_edit' )
@@ -133,6 +152,8 @@
self.remote_url = urlparse.urlunparse( tokens )
else:
self.remote_url = 'http://' + remote_url
+ if self.remote_url[-1] == '/':
+ self.remote_url = self.remote_url[:-1]
security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'edit' )
edit = WorkflowAction( _edit )
@@ -153,12 +174,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()
@@ -167,7 +186,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'],
@@ -184,11 +203,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.9 => 1.10 ===
-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: