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
75db0249
Commit
75db0249
authored
Dec 29, 2006
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
write() now auto-converts to unicode instead of throwing an exception
parent
ff875758
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
7 deletions
+4
-7
lib/python/Products/PageTemplates/ZopePageTemplate.py
lib/python/Products/PageTemplates/ZopePageTemplate.py
+4
-2
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
...thon/Products/PageTemplates/tests/testZopePageTemplate.py
+0
-5
No files found.
lib/python/Products/PageTemplates/ZopePageTemplate.py
View file @
75db0249
...
...
@@ -108,7 +108,6 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
self
.
expand
=
0
self
.
ZBindings_edit
(
self
.
_default_bindings
)
self
.
output_encoding
=
output_encoding
# default content
if
not
text
:
text
=
open
(
self
.
_default_content_fn
).
read
()
...
...
@@ -286,8 +285,11 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
return
c
def
write
(
self
,
text
):
if
not
isinstance
(
text
,
unicode
):
raise
TypeError
(
"'text' parameter must be unicode"
)
text
,
encoding
=
convertToUnicode
(
text
,
self
.
content_type
,
preferred_encodings
)
self
.
output_encoding
=
encoding
self
.
ZCacheable_invalidate
()
ZopePageTemplate
.
inheritedAttribute
(
'write'
)(
self
,
text
)
...
...
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
View file @
75db0249
...
...
@@ -112,11 +112,6 @@ class ZopePageTemplateFileTests(ZopeTestCase):
self
.
assertEqual
(
zpt
.
read
(),
s
)
self
.
assertEqual
(
isinstance
(
zpt
.
read
(),
unicode
),
True
)
def
testWriteWontAcceptsNonUnicode
(
self
):
manage_addPageTemplate
(
self
.
app
,
'test'
,
''
,
encoding
=
'utf-8'
)
zpt
=
self
.
app
[
'test'
]
self
.
assertRaises
(
TypeError
,
zpt
.
write
,
'this is not unicode'
)
def
_createZPT
(
self
):
manage_addPageTemplate
(
self
.
app
,
'test'
,
text
=
utf8_str
,
encoding
=
'utf-8'
)
...
...
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