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. # Copyright (c) 2005 Nexedi SARL. All Rights Reserved.
...@@ -93,8 +94,10 @@ class TextContent: ...@@ -93,8 +94,10 @@ class TextContent:
security.declarePrivate('guessFormat') security.declarePrivate('guessFormat')
def guessFormat(self, text): def guessFormat(self, text):
""" Simple stab at guessing the inner format of the text """ """ Simple stab at guessing the inner format of the text """
if html_headcheck(text): return 'html' if html_headcheck(text):
else: return 'structured-text' return 'text/html'
else:
return 'text/structured'
security.declarePrivate('handleText') security.declarePrivate('handleText')
def handleText(self, text, format=None): def handleText(self, text, format=None):
...@@ -102,7 +105,7 @@ class TextContent: ...@@ -102,7 +105,7 @@ class TextContent:
headers = {} headers = {}
if not format: if not format:
format = self.guessFormat(text) format = self.guessFormat(text)
if format == 'html': if format == 'text/html':
parser = SimpleHTMLParser() parser = SimpleHTMLParser()
parser.feed(text) parser.feed(text)
headers.update(parser.metatags) headers.update(parser.metatags)
...@@ -124,11 +127,8 @@ class TextContent: ...@@ -124,11 +127,8 @@ class TextContent:
try: try:
headers, body, format = self.handleText(text=body) headers, body, format = self.handleText(text=body)
if REQUEST.get_header('Content-Type', '') == 'text/html': content_type = REQUEST.get_header('Content-Type', '')
text_format = 'html' headers.setdefault('content_type', content_type)
else:
text_format = format
if not headers.has_key('text_format'): headers['text_format'] = text_format
headers['text_content'] = body headers['text_content'] = body
self._edit(**headers) self._edit(**headers)
except 'EditingConflict', msg: except 'EditingConflict', msg:
...@@ -161,7 +161,7 @@ class TextContent: ...@@ -161,7 +161,7 @@ class TextContent:
hdrlist = [] hdrlist = []
for p in self.getPropertyMap(): for p in self.getPropertyMap():
pid = p.get('base_id', p['id']) 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']))) hdrlist.append((pid, self.getProperty(p['id'])))
return hdrlist return hdrlist
...@@ -187,11 +187,11 @@ class TextContent: ...@@ -187,11 +187,11 @@ class TextContent:
bodytext = self._htmlsrc % { bodytext = self._htmlsrc % {
'title': self.getTitle(), 'title': self.getTitle(),
'metatags': hdrtext, 'metatags': hdrtext,
'body': self.getTextContent(), 'body': self.getTextContent(''),
} }
else: else:
hdrtext = formatRFC822Headers( hdrlist ) 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 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