comparison MoinMoin/parser/text_xslt.py @ 3824:aef3adf3f701

MoinMoinBugs/DoNotConvertUnicodeToUTF8ForXsltParser Initial patch applied and slightly improved.
author Thomas Pfaff <yael [at] gmx dot net>
date Fri, 11 Jul 2008 10:28:38 +0200
parents a1322262398a
children ff39884957af
comparison
equal deleted inserted replaced
3823:262738c1f46b 3824:aef3adf3f701
26 """ Send XML file formatted via XSLT. """ 26 """ Send XML file formatted via XSLT. """
27 caching = 1 27 caching = 1
28 Dependencies = Dependencies 28 Dependencies = Dependencies
29 29
30 def __init__(self, raw, request, **kw): 30 def __init__(self, raw, request, **kw):
31 self.raw = raw.encode(config.charset) 31 self.raw = raw
32 self.request = request 32 self.request = request
33 self.form = request.form 33 self.form = request.form
34 self._ = request.getText 34 self._ = request.getText
35 self.base_scheme = 'wiki' 35 self.base_scheme = 'wiki'
36 self.base_uri = 'wiki://Self/' 36 self.base_uri = 'wiki://Self/'
85 handlers={self.base_scheme: self._resolve_page, }, 85 handlers={self.base_scheme: self._resolve_page, },
86 base_scheme=self.base_scheme) 86 base_scheme=self.base_scheme)
87 input_factory = InputSource.InputSourceFactory(resolver=wiki_resolver) 87 input_factory = InputSource.InputSourceFactory(resolver=wiki_resolver)
88 88
89 page_uri = self.base_uri + wikiutil.url_quote(formatter.page.page_name) 89 page_uri = self.base_uri + wikiutil.url_quote(formatter.page.page_name)
90 raw = self.raw.strip() 90 # 4Suite needs an utf-8 encoded byte string instead of an unicode object
91 91 raw = self.raw.strip().encode('utf-8')
92 self.processor = Processor() 92 self.processor = Processor()
93 self.append_stylesheet() # hook, for extending this parser 93 self.append_stylesheet() # hook, for extending this parser
94 self.processor.run( 94 self.processor.run(
95 input_factory.fromString(raw, uri=page_uri), 95 input_factory.fromString(raw, uri=page_uri),
96 outputStream=out_file) 96 outputStream=out_file)
97 result = out_file.getvalue() 97 # Convert utf-8 encoded byte string into unicode
98 result = out_file.getvalue().decode('utf-8')
98 result = self.parse_result(result) # hook, for extending this parser 99 result = self.parse_result(result) # hook, for extending this parser
99 100
100 except FtException, msg: 101 except FtException, msg:
101 etype = "XSLT" 102 etype = "XSLT"
102 except Uri.UriException, msg: 103 except Uri.UriException, msg: