[Zope-Checkins]
SVN: Zope/branches/ajung-zpt-integration/lib/python/Products/PageTemplates/ZopePageTemplate.py
replace __setstate__() (migration) with manage_convertUnicode()
Andreas Jung
andreas at andreas-jung.com
Fri Jan 6 06:03:52 EST 2006
Log message for revision 41165:
replace __setstate__() (migration) with manage_convertUnicode()
Changed:
U Zope/branches/ajung-zpt-integration/lib/python/Products/PageTemplates/ZopePageTemplate.py
-=-
Modified: Zope/branches/ajung-zpt-integration/lib/python/Products/PageTemplates/ZopePageTemplate.py
===================================================================
--- Zope/branches/ajung-zpt-integration/lib/python/Products/PageTemplates/ZopePageTemplate.py 2006-01-05 21:12:02 UTC (rev 41164)
+++ Zope/branches/ajung-zpt-integration/lib/python/Products/PageTemplates/ZopePageTemplate.py 2006-01-06 11:03:50 UTC (rev 41165)
@@ -369,23 +369,30 @@
return 0
- def __setstate__(self, state):
+ def manage_convertUnicode(self, preferred_encodings=preferred_encodings, RESPONSE=None):
""" convert non-unicode templates to unicode """
- text = state['_text']
- if not isinstance(text, unicode):
- # ATT: the encoding guessing should be made more flexible
+ if not isinstance(self._text, unicode):
+
for encoding in preferred_encodings:
try:
- state['_text'] = unicode(text, encoding)
- self.__dict__.update(state)
- return
+ self._text = unicode(self._text, encoding)
+ if RESPONSE:
+ return RESPONSE.redirect(self.absolute_url() + '/pt_editForm?manage_tabs_message=ZPT+successfully+converted')
+ else:
+ return
except UnicodeDecodeError:
pass
- raise RuntimeError('Pagetemplate could not be converted to unicode')
-
+ raise RuntimeError('Pagetemplate could not be converted to unicode')
+ else:
+ if RESPONSE:
+ return RESPONSE.redirect(self.absolute_url() + '/pt_editForm?manage_tabs_message=ZPT+already+converted')
+ else:
+ return
+
+
security.declareProtected(view_management_screens, 'getSource')
getSource = Src()
source_dot_xml = Src()
More information about the Zope-Checkins
mailing list