Commit 365048fd authored by Andreas Jung's avatar Andreas Jung

- savepoint

- title attribute is now a ustring propery
- some not working preparations to get rid of original ZPT dependencies
parent d07124fc
...@@ -40,7 +40,8 @@ from AccessControl.Permissions import view, ftp_access, change_page_templates, v ...@@ -40,7 +40,8 @@ from AccessControl.Permissions import view, ftp_access, change_page_templates, v
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
from webdav.WriteLockInterface import WriteLockInterface 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): class Src(Acquisition.Explicit):
""" I am scary code """ """ I am scary code """
...@@ -57,6 +58,8 @@ class Src(Acquisition.Explicit): ...@@ -57,6 +58,8 @@ class Src(Acquisition.Explicit):
return self.document_src(REQUEST) return self.document_src(REQUEST)
class ZPT(Script, PageTemplate, Historical, Cacheable, class ZPT(Script, PageTemplate, Historical, Cacheable,
Traversable, PropertyManager): Traversable, PropertyManager):
""" Z2 wrapper class for Zope 3 page templates """ """ Z2 wrapper class for Zope 3 page templates """
...@@ -131,16 +134,10 @@ class ZPT(Script, PageTemplate, Historical, Cacheable, ...@@ -131,16 +134,10 @@ class ZPT(Script, PageTemplate, Historical, Cacheable,
security.declareProtected(change_page_templates, 'pt_setTitle') security.declareProtected(change_page_templates, 'pt_setTitle')
def pt_setTitle(self, title): def pt_setTitle(self, title, encoding='utf-8'):
charset = getattr(self, 'management_page_charset', None)
if isinstance(title, str) and charset: if not isinstance(title, unicode):
try: title = unicode(title, encoding)
title.decode('us-ascii')
title = str(title)
except UnicodeError:
title = unicode(title, charset)
elif not isinstance(title, unicode):
title = str(title)
self._setPropValue('title', title) self._setPropValue('title', title)
security.declareProtected(change_page_templates, 'pt_upload') security.declareProtected(change_page_templates, 'pt_upload')
...@@ -349,9 +346,8 @@ class ZPT(Script, PageTemplate, Historical, Cacheable, ...@@ -349,9 +346,8 @@ class ZPT(Script, PageTemplate, Historical, Cacheable,
source_dot_xml = Src() source_dot_xml = Src()
security.declareProtected(view_management_screens, 'pt_editForm') security.declareProtected(view_management_screens, 'pt_editForm')
pt_editForm = PageTemplateFile('pt/ptEdit', globals(), pt_editForm = PageTemplateFile('pt/ptEdit.pt', globals())
__name__='pt_editForm') pt_editForm.__name__ = 'pt_editForm'
pt_editForm._owner = None
manage = manage_main = pt_editForm manage = manage_main = pt_editForm
...@@ -361,9 +357,22 @@ InitializeClass(ZPT) ...@@ -361,9 +357,22 @@ InitializeClass(ZPT)
setattr(ZPT, 'source.xml', ZPT.source_dot_xml) setattr(ZPT, 'source.xml', ZPT.source_dot_xml)
setattr(ZPT, 'source.html', 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 # Product registration and Add support
manage_addZPTForm= PageTemplateFile( manage_addZPTForm= PageTemplateFile('pt/ptAdd.pt', globals())
'pt/ptAdd', globals(), __name__='manage_addPageTemplateForm') 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, def manage_addZPT(self, id, title=None, text=None,
......
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