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
a717c7be
Commit
a717c7be
authored
Aug 02, 2008
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deal with the case that 'context' must not have a REQUEST object
(test comes later)
parent
33343447
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
lib/python/Products/PageTemplates/unicodeconflictresolver.py
lib/python/Products/PageTemplates/unicodeconflictresolver.py
+25
-8
No files found.
lib/python/Products/PageTemplates/unicodeconflictresolver.py
View file @
a717c7be
...
...
@@ -62,25 +62,42 @@ class PreferredCharsetResolver:
def
resolve
(
self
,
context
,
text
,
expression
):
request
=
context
.
REQUEST
request
=
getattr
(
context
,
'REQUEST'
,
None
)
charsets
=
getattr
(
request
,
'__zpt_available_charsets'
,
None
)
if
charsets
is
None
:
charsets
=
IUserPreferredCharsets
(
request
).
getPreferredCharsets
()
# add management_page_charset as one fallback
# Deal with the fact that a REQUEST is not always available.
# In this case fall back to the encoding of the ZMI and the
# Python default encoding.
if
request
is
None
:
charsets
=
[
default_encoding
]
management_charset
=
getattr
(
context
,
'management_page_charset'
,
None
)
if
management_charset
:
charsets
.
append
(
management_charset
)
charsets
.
insert
(
0
,
management_charset
)
else
:
# charsets might by cached within the request
charsets
=
getattr
(
request
,
'__zpt_available_charsets'
,
None
)
# No uncached charsets found: investigate the HTTP_ACCEPT_CHARSET
# header. This code is only called if 'context' has a request
# object. The condition is true because otherwise 'charsets' contains
# at least the default encoding of Python.
if
charsets
is
None
:
charsets
=
list
()
# add Python's default encoding as last fallback
charsets
.
append
(
default_encoding
)
# include the charsets based on the HTTP_ACCEPT_CHARSET
# header
charsets
=
IUserPreferredCharsets
(
request
).
getPreferredCharsets
()
+
\
charsets
# cache list of charsets
request
.
__zpt_available_charsets
=
charsets
for
enc
in
charsets
:
if
enc
==
'*'
:
continue
if
enc
==
'*'
:
continue
try
:
return
unicode
(
text
,
enc
)
...
...
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