[Zope-Checkins] SVN: Zope/branches/ajung-zpt-integration/lib/python/Products/ZPT/ZPT.py - savepoint

Andreas Jung andreas at andreas-jung.com
Fri Dec 9 12:32:32 EST 2005


Log message for revision 40671:
  - savepoint
  - title attribute is now a ustring propery
  - some not working preparations to get rid of original ZPT dependencies
  

Changed:
  U   Zope/branches/ajung-zpt-integration/lib/python/Products/ZPT/ZPT.py

-=-
Modified: Zope/branches/ajung-zpt-integration/lib/python/Products/ZPT/ZPT.py
===================================================================
--- Zope/branches/ajung-zpt-integration/lib/python/Products/ZPT/ZPT.py	2005-12-09 17:31:16 UTC (rev 40670)
+++ Zope/branches/ajung-zpt-integration/lib/python/Products/ZPT/ZPT.py	2005-12-09 17:32:31 UTC (rev 40671)
@@ -40,7 +40,8 @@
 from webdav.Lockable import ResourceLockedError
 from webdav.WriteLockInterface import WriteLockInterface
 
-from zope.pagetemplate.pagetemplate import PageTemplate
+from zope.pagetemplate.pagetemplate import PageTemplate 
+#from zope.pagetemplate.pagetemplatefile import PageTemplateFile
 
 class Src(Acquisition.Explicit):
     """ I am scary code """
@@ -57,6 +58,8 @@
         return self.document_src(REQUEST)
 
 
+
+
 class ZPT(Script, PageTemplate, Historical, Cacheable,
                        Traversable, PropertyManager):
     """ Z2 wrapper class for Zope 3 page templates """
@@ -131,16 +134,10 @@
 
 
     security.declareProtected(change_page_templates, 'pt_setTitle')
-    def pt_setTitle(self, title):
-        charset = getattr(self, 'management_page_charset', None)
-        if isinstance(title, str) and charset:
-            try:
-                title.decode('us-ascii')
-                title = str(title)
-            except UnicodeError:
-                title = unicode(title, charset)
-        elif not isinstance(title, unicode):
-            title = str(title)
+    def pt_setTitle(self, title, encoding='utf-8'):
+        
+        if not isinstance(title, unicode):
+            title = unicode(title, encoding)
         self._setPropValue('title', title)
 
     security.declareProtected(change_page_templates, 'pt_upload')
@@ -349,9 +346,8 @@
     source_dot_xml = Src()
 
     security.declareProtected(view_management_screens, 'pt_editForm')
-    pt_editForm = PageTemplateFile('pt/ptEdit', globals(),
-                                   __name__='pt_editForm')
-    pt_editForm._owner = None
+    pt_editForm = PageTemplateFile('pt/ptEdit.pt', globals())
+    pt_editForm.__name__ = 'pt_editForm'
     manage = manage_main = pt_editForm
 
 
@@ -361,9 +357,22 @@
 setattr(ZPT, 'source.xml',  ZPT.source_dot_xml)
 setattr(ZPT, 'source.html', ZPT.source_dot_xml)
 
+
+
+class FSZPT(ZPT):
+
+    def __init__(self, filename, name):
+        self.__name__= name
+        PageTemplate.__init__(self, open(filename).read(), 'text/html')
+
+InitializeClass(FSZPT)
+
+
 # Product registration and Add support
-manage_addZPTForm= PageTemplateFile(
-    'pt/ptAdd', globals(), __name__='manage_addPageTemplateForm')
+manage_addZPTForm= PageTemplateFile('pt/ptAdd.pt', globals())
+manage_addZPTForm.__name__ = 'manage_addZPTForm'
+#manage_addZPTForm= FSZPT(os.path.join(package_home(globals()), 'pt', 'ptAdd.pt'), 'manage_addZPTForm')
+#manage_addZPTForm.__name__ = 'manage_addZPTForm'
 
 
 def manage_addZPT(self, id, title=None, text=None,



More information about the Zope-Checkins mailing list