[Erp5-report] r35245 nicolas - /erp5/trunk/products/ERP5Type/WebDAVSupport.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed May 12 18:40:02 CEST 2010
Author: nicolas
Date: Wed May 12 18:39:57 2010
New Revision: 35245
URL: http://svn.erp5.org?rev=35245&view=rev
Log:
Follow last TextDocument refactoring, text_format is replaced
by content_type
Enable WebDav edition of TextDocument. Works if encoded is not uft-8
Modified:
erp5/trunk/products/ERP5Type/WebDAVSupport.py
Modified: erp5/trunk/products/ERP5Type/WebDAVSupport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/WebDAVSupport.py?rev=35245&r1=35244&r2=35245&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/WebDAVSupport.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/WebDAVSupport.py [utf8] Wed May 12 18:39:57 2010
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL. All Rights Reserved.
@@ -93,8 +94,10 @@
security.declarePrivate('guessFormat')
def guessFormat(self, text):
""" Simple stab at guessing the inner format of the text """
- if html_headcheck(text): return 'html'
- else: return 'structured-text'
+ if html_headcheck(text):
+ return 'text/html'
+ else:
+ return 'text/structured'
security.declarePrivate('handleText')
def handleText(self, text, format=None):
@@ -102,7 +105,7 @@
headers = {}
if not format:
format = self.guessFormat(text)
- if format == 'html':
+ if format == 'text/html':
parser = SimpleHTMLParser()
parser.feed(text)
headers.update(parser.metatags)
@@ -124,11 +127,8 @@
try:
headers, body, format = self.handleText(text=body)
- if REQUEST.get_header('Content-Type', '') == 'text/html':
- text_format = 'html'
- else:
- text_format = format
- if not headers.has_key('text_format'): headers['text_format'] = text_format
+ content_type = REQUEST.get_header('Content-Type', '')
+ headers.setdefault('content_type', content_type)
headers['text_content'] = body
self._edit(**headers)
except 'EditingConflict', msg:
@@ -161,7 +161,7 @@
hdrlist = []
for p in self.getPropertyMap():
pid = p.get('base_id', p['id'])
- if pid not in ('text_content',):
+ if pid not in ('text_content', 'data', 'base_data'):
hdrlist.append((pid, self.getProperty(p['id'])))
return hdrlist
@@ -187,11 +187,11 @@
bodytext = self._htmlsrc % {
'title': self.getTitle(),
'metatags': hdrtext,
- 'body': self.getTextContent(),
+ 'body': self.getTextContent(''),
}
else:
hdrtext = formatRFC822Headers( hdrlist )
- bodytext = '%s\r\n\r\n%s' % ( hdrtext, self.getTextContent() )
+ bodytext = '%s\r\n\r\n%s' % ( hdrtext, self.getTextContent('') )
return bodytext
More information about the Erp5-report
mailing list