Commit 8e690dca authored by Nicolas Delaby's avatar Nicolas Delaby

Follow last TextDocument refactoring, text_format is replaced

by content_type
Enable WebDav edition of TextDocument. Works if encoded is not uft-8


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35245 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3c989a7e
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL. All Rights Reserved.
......@@ -93,8 +94,10 @@ class TextContent:
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 @@ class TextContent:
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 @@ class TextContent:
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 @@ class TextContent:
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 @@ class TextContent:
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment