Commit 200006dc authored by Andreas Jung's avatar Andreas Jung

added backward compatibility with non-unicode ZPT instance

by providing a (dumb) implicit conversion (needs more cleverness)
parent ec56ce7e
...@@ -280,6 +280,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -280,6 +280,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
# XXX: check the parameters for pt_render()! (aj) # XXX: check the parameters for pt_render()! (aj)
result = self.pt_render(self.pt_getContext()) result = self.pt_render(self.pt_getContext())
# result = self.pt_render(extra_context=bound_names) # result = self.pt_render(extra_context=bound_names)
if keyset is not None: if keyset is not None:
# Store the result in the cache. # Store the result in the cache.
...@@ -350,6 +351,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -350,6 +351,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
'title': 'This template has an error'},) 'title': 'This template has an error'},)
return icons return icons
security.declareProtected(view, 'pt_source_file') security.declareProtected(view, 'pt_source_file')
def pt_source_file(self): def pt_source_file(self):
"""Returns a file name to be compiled into the TAL code.""" """Returns a file name to be compiled into the TAL code."""
...@@ -363,6 +365,24 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -363,6 +365,24 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
def wl_isLocked(self): def wl_isLocked(self):
return 0 return 0
def __setstate__(self, state):
""" convert non-unicode templates to unicode """
text = state['_text']
if not isinstance(text, unicode):
# ATT: the encoding guessing should be made more flexible
for encoding in ('iso-8859-15', 'utf-8'):
try:
state['_text'] = unicode(text, encoding)
self.__dict__.update(state)
return
except UnicodeDecodeError:
pass
raise RuntimeError('Pagetemplate could not be converted to unicode')
security.declareProtected(view_management_screens, 'getSource') security.declareProtected(view_management_screens, 'getSource')
getSource = Src() getSource = Src()
source_dot_xml = Src() source_dot_xml = Src()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment