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
9c4e2f0d
Commit
9c4e2f0d
authored
Jan 06, 2007
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some lame solution but that actually works pretty well
parent
68642d31
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
lib/python/Products/PageTemplates/Expressions.py
lib/python/Products/PageTemplates/Expressions.py
+47
-0
No files found.
lib/python/Products/PageTemplates/Expressions.py
View file @
9c4e2f0d
...
...
@@ -17,6 +17,9 @@ for Python expressions, string literals, and paths.
$Id$
"""
import
sys
from
zope.interface
import
implements
from
zope.tales.tales
import
Context
,
Iterator
from
zope.tales.expressions
import
PathExpr
,
StringExpr
,
NotExpr
...
...
@@ -173,6 +176,50 @@ class ZopeContext(Context):
domain
,
msgid
,
mapping
=
mapping
,
context
=
context
,
default
=
default
)
def
evaluateText
(
self
,
expr
):
""" customized version in order to get rid of unicode
errors for all and ever
"""
text
=
self
.
evaluate
(
expr
)
# print expr, repr(text), text.__class__
if
text
is
self
.
getDefault
()
or
text
is
None
:
return
text
if
isinstance
(
text
,
unicode
):
# we love unicode, nothing to do
return
text
elif
isinstance
(
text
,
str
):
# waahhh...a standard string
# trying to be somewhat smart...this must be
# replaced with some kind of configurable
# UnicodeEncodingConflictResolver (what a name)
try
:
return
unicode
(
text
)
except
UnicodeDecodeError
:
# check for management_page_charset property, default to Python's
# default encoding
encoding
=
getattr
(
self
.
contexts
[
'context'
],
'management_page_charset'
,
sys
.
getdefaultencoding
())
try
:
return
unicode
(
text
,
encoding
)
except
UnicodeDecodeError
:
# errors='replace' sucks...it's fine for now
return
unicode
(
text
,
encoding
,
'replace'
)
else
:
# This is a weird culprit ...calling unicode() on non-string
# objects
return
unicode
(
text
)
class
ZopeEngine
(
zope
.
app
.
pagetemplate
.
engine
.
ZopeEngine
):
_create_context
=
ZopeContext
...
...
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