Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
29f0205d
Commit
29f0205d
authored
Jan 14, 2007
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backported woraround for unicode issue in
zope.tal.xmlparser.XMLParser.parseString()
parent
892a3e8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
lib/python/Products/PageTemplates/__init__.py
lib/python/Products/PageTemplates/__init__.py
+23
-0
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
...thon/Products/PageTemplates/tests/testZopePageTemplate.py
+2
-0
No files found.
lib/python/Products/PageTemplates/__init__.py
View file @
29f0205d
...
...
@@ -26,7 +26,30 @@ misc_ = {}
# available in sys.modules
import
ZTUtils
def
initialize
(
context
):
# Import lazily, and defer initialization to the module
import
ZopePageTemplate
ZopePageTemplate
.
initialize
(
context
)
# HACK!!!
# We need to monkeypatch the parseString method of the Zope 3
# XMLParser since the internal ZPT representation uses unicode
# however the XMLParser (using Expat) can only deal with standard
# Python strings. However we won't and can't convert directly
# to UTF-8 within the ZPT wrapper code.
# Unicode support for (this issue) should be directly added
# to zope.tal.xmlparser however this requires a new Zope 3.3.X
# release. For now we fix it here.
from
zope.tal.xmlparser
import
XMLParser
import
logging
def
parseString
(
self
,
s
):
if
isinstance
(
s
,
unicode
):
s
=
s
.
encode
(
'utf-8'
)
self
.
parser
.
Parse
(
s
,
1
)
XMLParser
.
parseString
=
parseString
logging
.
info
(
'Monkeypatching zope.tal.xmlparser.XMLParser.parseString()'
)
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
View file @
29f0205d
...
...
@@ -196,12 +196,14 @@ class ZopePageTemplateFileTests(ZopeTestCase):
zpt
=
self
.
_put
(
xml_iso_8859_15
)
self
.
assertEqual
(
zpt
.
output_encoding
,
'utf-8'
)
self
.
assertEqual
(
zpt
.
content_type
,
'text/xml'
)
result
=
zpt
.
pt_render
()
# should not raise an exception
def
testPutXMLUTF8
(
self
):
""" XML: use always UTF-8 als output encoding """
zpt
=
self
.
_put
(
xml_utf8
)
self
.
assertEqual
(
zpt
.
output_encoding
,
'utf-8'
)
self
.
assertEqual
(
zpt
.
content_type
,
'text/xml'
)
result
=
zpt
.
pt_render
()
# should not raise an exception
class
ZPTRegressions
(
unittest
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment