Log message for revision 40651:
eeek...Zope 3 ZPTs now work in Zope 2 :-)
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 10:07:57 UTC (rev 40650)
+++ Zope/branches/ajung-zpt-integration/lib/python/Products/ZPT/ZPT.py
2005-12-09 14:25:51 UTC (rev 40651)
@@ -17,69 +17,365 @@
__version__='$Revision: 1.48 $'[11:-2]
+import os, AccessControl, Acquisition, sys, types
from types import StringType
-from Globals import DTMLFile, ImageFile, MessageDialog, package_home,
Persistent
+from Globals import DTMLFile, ImageFile, MessageDialog, package_home
from zLOG import LOG, ERROR, INFO
from OFS.SimpleItem import SimpleItem
-import AccessControl
+from DateTime.DateTime import DateTime
+from Shared.DC.Scripts.Script import Script, BindingsUI
+from Shared.DC.Scripts.Signature import FuncCode
from AccessControl import getSecurityManager
-
-from zope.pagetemplate.pagetemplate import PageTemplate
+try:
+from AccessControl import Unauthorized
+except ImportError:
+Unauthorized = Unauthorized
+from OFS.History import Historical, html_diff
+from OFS.Cache import Cacheable
+from OFS.Traversable import Traversable
+from OFS.PropertyManager import PropertyManager
+#from PageTemplate import PageTemplate
+from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-class ZPT(SimpleItem, PageTemplate):
+try:
+from webdav.Lockable import ResourceLockedError
+from webdav.WriteLockInterface import WriteLockInterface
+SUPPORTS_WEBDAV_LOCKS = 1
+except ImportError:
+SUPPORTS_WEBDAV_LOCKS = 0
+
+
+from zope.pagetemplate.pagetemplate import PageTemplate
+
+class Src(Acquisition.Explicit):
+
+
+PUT = document_src = Acquisition.Acquired
+index_html = None
+
+def __before_publishing_traverse__(self, ob, request):
+if getattr(request, '_hacked_path', 0):
+request._hacked_path = 0
+
+def __call__(self, REQUEST, RESPONSE):
+
+return self.document_src(REQUEST)
+
+
+class ZPT(Script, PageTemplate, Historical, Cacheable,
+ Traversable, PropertyManager):
Zope wrapper for Page Template using TAL, TALES, and METAL
+if SUPPORTS_WEBDAV_LOCKS:
+__implements__ = (WriteLockInterface,)
+
meta_type = 'ZPT'
+func_defaults = None
+func_code = FuncCode((), 0)
+
+_default_bindings = {'name_subpath': 'traverse_subpath'}
+_default_content_fn = os.path.join(package_home(globals()),
+ 'www', 'default.html')
+
manage_options = (
{'label':'Edit', 'action':'pt_editForm',
'help': ('PageTemplates', 'PageTemplate_Edit.stx')},
{'label':'Test', 'action':'ZScriptHTML_tryForm'},
-) \
+) + PropertyManager.manage_options \
++ Historical.manage_options \
+ SimpleItem.manage_options \
-
-security = AccessControl.ClassSecurityInfo()
++ Cacheable.manage_options
+_properties=({'id':'title', 'type': 'string', 'mode': 'wd'},
+ {'id':'content_type', 'type':'string', 'mode': 'w'},
+ {'id':'expand', 'type':'boolean', 'mode': 'w'},
+ )
+
def __init__(self, id, text=None, content_type=None):
self.id = str(id)
+self.ZBindings_edit(self._default_bindings)
+if text is None:
+text = open(self._default_content_fn).read()
+self.pt_edit(text, content_type)
+def _setPropValue(self, id, value):
+PropertyManager._setPropValue(self, id, value)
+self.ZCacheable_invalidate()
+
+security = AccessControl.ClassSecurityInfo()
+
+security.declareObjectProtected('View')
security.declareProtected('View', '__call__')
-security.declareProtected('View', 'view')
-def view(self):
-view
-return self()
+security.declareProtected('View management screens',
+ 'pt_editForm', 'manage_main', 'read',
+ 'ZScriptHTML_tryForm', 'PrincipiaSearchSource',
+ 'document_src', 'source_dot_xml')
+
+security.declareProtected('FTP access',
+ 'manage_FTPstat','manage_FTPget','manage_FTPlist')
+
+pt_editForm = PageTemplateFile('www/ptEdit', globals(),
+ __name__='pt_editForm')
+pt_editForm._owner = None
+manage = manage_main = pt_editForm
+
+source_dot_xml = Src()
+
security.declareProtected('Change Page Templates',
'pt_editAction', 'pt_setTitle', 'pt_edit',
'pt_upload', 'pt_changePrefs')
def pt_editAction(self, REQUEST, title, text, content_type, expand):
Change the title and document.
-
-print text
-print content_type
+