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
c3653237
Commit
c3653237
authored
Mar 08, 2009
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- replaced getattr by aq_get
- whitespace cleanup
parent
1f35ed1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
doc/CHANGES.rst
doc/CHANGES.rst
+3
-0
src/Products/PageTemplates/unicodeconflictresolver.py
src/Products/PageTemplates/unicodeconflictresolver.py
+12
-6
No files found.
doc/CHANGES.rst
View file @
c3653237
...
...
@@ -35,6 +35,9 @@ Restructuring
Bugs Fixed
++++++++++
- PageTemplates: Made PreferredCharsetResolver work with new kinds of contexts
that are not acquisition wrapped.
- Object managers should evaluate to True in a boolean test.
2.12.0a1 (2009-02-26)
...
...
src/Products/PageTemplates/unicodeconflictresolver.py
View file @
c3653237
...
...
@@ -10,16 +10,21 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Unicode conflict resolution.
$Id$
"""
import
sys
from
Acquisition
import
aq_get
from
Products.PageTemplates.interfaces
import
IUnicodeEncodingConflictResolver
from
zope.interface
import
implements
from
zope.i18n.interfaces
import
IUserPreferredCharsets
from
Products.PageTemplates.interfaces
import
IUnicodeEncodingConflictResolver
default_encoding
=
sys
.
getdefaultencoding
()
class
DefaultUnicodeEncodingConflictResolver
:
""" This resolver implements the old-style behavior and will
raise an exception in case of the string 'text' can't be converted
...
...
@@ -53,6 +58,7 @@ class Z2UnicodeEncodingConflictResolver:
encoding
=
getattr
(
context
,
'management_page_charset'
,
default_encoding
)
return
unicode
(
text
,
encoding
,
self
.
mode
)
class
PreferredCharsetResolver
:
""" A resolver that tries use the encoding information
from the HTTP_ACCEPT_CHARSET header.
...
...
@@ -62,7 +68,7 @@ class PreferredCharsetResolver:
def
resolve
(
self
,
context
,
text
,
expression
):
request
=
getattr
(
context
,
'REQUEST'
,
None
)
request
=
aq_get
(
context
,
'REQUEST'
,
None
)
# Deal with the fact that a REQUEST is not always available.
# In this case fall back to the encoding of the ZMI and the
...
...
@@ -74,7 +80,7 @@ class PreferredCharsetResolver:
if
management_charset
:
charsets
.
insert
(
0
,
management_charset
)
else
:
# charsets might by cached within the request
# charsets might by cached within the request
charsets
=
getattr
(
request
,
'__zpt_available_charsets'
,
None
)
# No uncached charsets found: investigate the HTTP_ACCEPT_CHARSET
...
...
@@ -86,12 +92,12 @@ class PreferredCharsetResolver:
charsets
=
list
()
# add Python's default encoding as last fallback
charsets
.
append
(
default_encoding
)
charsets
.
append
(
default_encoding
)
# include the charsets based on the HTTP_ACCEPT_CHARSET
# header
charsets
=
IUserPreferredCharsets
(
request
).
getPreferredCharsets
()
+
\
charsets
charsets
# cache list of charsets
request
.
__zpt_available_charsets
=
charsets
...
...
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