Log message for revision 41149:
  added backward compatibility with non-unicode ZPT instance
  by providing a (dumb) implicit conversion (needs more cleverness)
  

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 14:21:20 UTC (rev 41148)
+++ 
Zope/branches/ajung-zpt-integration/lib/python/Products/PageTemplates/ZopePageTemplate.py
   2006-01-05 15:08:38 UTC (rev 41149)
@@ -279,6 +279,7 @@
         try:
             # XXX: check the parameters for pt_render()! (aj)
             result = self.pt_render(self.pt_getContext())
+        
 
 #            result = self.pt_render(extra_context=bound_names)
             if keyset is not None:
@@ -350,6 +351,7 @@
                               'title': 'This template has an error'},)
         return icons
 
+
     security.declareProtected(view, 'pt_source_file')
     def pt_source_file(self):
         """Returns a file name to be compiled into the TAL code."""
@@ -363,6 +365,24 @@
     def wl_isLocked(self):
         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')
     getSource = Src()
     source_dot_xml = Src()

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to