Commit ea3765d4 authored by Evan Simpson's avatar Evan Simpson

Merge bugfixes from zpt-1_4_0

parent 7cbbf24c
...@@ -89,7 +89,7 @@ Page Template-specific implementation of TALES, with handlers ...@@ -89,7 +89,7 @@ Page Template-specific implementation of TALES, with handlers
for Python expressions, string literals, and paths. for Python expressions, string literals, and paths.
""" """
__version__='$Revision: 1.21 $'[11:-2] __version__='$Revision: 1.22 $'[11:-2]
import re, sys import re, sys
from TALES import Engine, CompilerError, _valid_name, NAME_RE, \ from TALES import Engine, CompilerError, _valid_name, NAME_RE, \
...@@ -125,6 +125,7 @@ if sys.modules.has_key('Zope'): ...@@ -125,6 +125,7 @@ if sys.modules.has_key('Zope'):
else: else:
from ZPythonExpr import PythonExpr, _SecureModuleImporter, \ from ZPythonExpr import PythonExpr, _SecureModuleImporter, \
call_with_ns call_with_ns
SecureModuleImporter = _SecureModuleImporter()
else: else:
from PythonExpr import getSecurityManager, PythonExpr from PythonExpr import getSecurityManager, PythonExpr
def call_with_ns(f, ns, arg=1): def call_with_ns(f, ns, arg=1):
......
...@@ -4,6 +4,22 @@ Page Template history ...@@ -4,6 +4,22 @@ Page Template history
PageTemplates. Change information for the current release can be found PageTemplates. Change information for the current release can be found
in the file CHANGES.txt. in the file CHANGES.txt.
Version 1.4.1
Bugs Fixed
- Tracebacks were often truncated.
- __bobo_traverse__ objects, such as the root, triggered
security incorrectly when traversed.
- If a PageTemplate was owned by a missing user, or one with
insufficient permissions, the editing form broke.
- PageTemplateFiles didn't bind 'user'.
- There was no help.
Version 1.4.0 Version 1.4.0
Features Added Features Added
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
Zope object encapsulating a Page Template from the filesystem. Zope object encapsulating a Page Template from the filesystem.
""" """
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
import os, AccessControl, Acquisition, sys import os, AccessControl, Acquisition, sys
from Globals import package_home, DevelopmentMode from Globals import package_home, DevelopmentMode
...@@ -98,8 +98,14 @@ from Shared.DC.Scripts.Signature import FuncCode ...@@ -98,8 +98,14 @@ from Shared.DC.Scripts.Signature import FuncCode
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from OFS.Traversable import Traversable from OFS.Traversable import Traversable
from PageTemplate import PageTemplate from PageTemplate import PageTemplate
from ZopePageTemplate import SecureModuleImporter from Expressions import SecureModuleImporter
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from ExtensionClass import Base
class MacroCollection(Base):
def __of__(self, parent):
parent._cook_check()
return parent._v_macros
class PageTemplateFile(Script, PageTemplate, Traversable): class PageTemplateFile(Script, PageTemplate, Traversable):
"Zope wrapper for filesystem Page Template using TAL, TALES, and METAL" "Zope wrapper for filesystem Page Template using TAL, TALES, and METAL"
...@@ -110,6 +116,7 @@ class PageTemplateFile(Script, PageTemplate, Traversable): ...@@ -110,6 +116,7 @@ class PageTemplateFile(Script, PageTemplate, Traversable):
func_code = FuncCode((), 0) func_code = FuncCode((), 0)
_need__name__=1 _need__name__=1
_v_last_read=0 _v_last_read=0
macros = MacroCollection()
_default_bindings = {'name_subpath': 'traverse_subpath'} _default_bindings = {'name_subpath': 'traverse_subpath'}
...@@ -125,8 +132,8 @@ class PageTemplateFile(Script, PageTemplate, Traversable): ...@@ -125,8 +132,8 @@ class PageTemplateFile(Script, PageTemplate, Traversable):
elif type(_prefix) is not type(''): elif type(_prefix) is not type(''):
_prefix = package_home(_prefix) _prefix = package_home(_prefix)
name = kw.get('__name__') name = kw.get('__name__')
if not name: if name:
name = os.path.split(filename)[-1] self._need__name__ = 0
self.__name__ = name self.__name__ = name
self.filename = filename = os.path.join(_prefix, filename + '.zpt') self.filename = filename = os.path.join(_prefix, filename + '.zpt')
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
Zope object encapsulating a Page Template. Zope object encapsulating a Page Template.
""" """
__version__='$Revision: 1.19 $'[11:-2] __version__='$Revision: 1.20 $'[11:-2]
import os, AccessControl, Acquisition, sys import os, AccessControl, Acquisition, sys
from Globals import DTMLFile, MessageDialog, package_home from Globals import DTMLFile, MessageDialog, package_home
...@@ -104,6 +104,8 @@ from OFS.Traversable import Traversable ...@@ -104,6 +104,8 @@ from OFS.Traversable import Traversable
from OFS.PropertyManager import PropertyManager from OFS.PropertyManager import PropertyManager
from PageTemplate import PageTemplate from PageTemplate import PageTemplate
from TALES import TALESError from TALES import TALESError
from Expressions import SecureModuleImporter
from PageTemplateFile import PageTemplateFile
try: try:
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
...@@ -124,12 +126,13 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -124,12 +126,13 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
func_defaults = None func_defaults = None
func_code = FuncCode((), 0) func_code = FuncCode((), 0)
_default_bindings = {'name_subpath': 'traverse_subpath'} _default_bindings = {}
_default_content_fn = os.path.join(package_home(globals()), _default_content_fn = os.path.join(package_home(globals()),
'www', 'default.html') 'www', 'default.html')
manage_options = ( manage_options = (
{'label':'Edit', 'action':'pt_editForm'}, {'label':'Edit', 'action':'pt_editForm',
'help': ('PageTemplates', 'PageTemplate_Edit.stx')},
{'label':'Test', 'action':'ZScriptHTML_tryForm'}, {'label':'Test', 'action':'ZScriptHTML_tryForm'},
) + PropertyManager.manage_options \ ) + PropertyManager.manage_options \
+ Historical.manage_options \ + Historical.manage_options \
...@@ -162,6 +165,11 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -162,6 +165,11 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
'ZScriptHTML_tryForm', 'PrincipiaSearchSource', 'ZScriptHTML_tryForm', 'PrincipiaSearchSource',
'document_src', 'source.html', 'source.xml') 'document_src', 'source.html', 'source.xml')
pt_editForm = PageTemplateFile('www/ptEdit', globals(),
__name__='pt_editForm')
pt_editForm._owner = None
manage = manage_main = pt_editForm
security.declareProtected('Change Page Templates', security.declareProtected('Change Page Templates',
'pt_editAction', 'pt_setTitle', 'pt_edit', 'pt_editAction', 'pt_setTitle', 'pt_edit',
'pt_upload', 'pt_changePrefs') 'pt_upload', 'pt_changePrefs')
...@@ -335,10 +343,9 @@ class Src(Acquisition.Explicit): ...@@ -335,10 +343,9 @@ class Src(Acquisition.Explicit):
d = ZopePageTemplate.__dict__ d = ZopePageTemplate.__dict__
d['source.xml'] = d['source.html'] = Src() d['source.xml'] = d['source.html'] = Src()
from Expressions import _SecureModuleImporter
SecureModuleImporter = _SecureModuleImporter()
# Product registration and Add support # Product registration and Add support
manage_addPageTemplateForm = PageTemplateFile('www/ptAdd', globals())
from urllib import quote from urllib import quote
def manage_addPageTemplate(self, id, title=None, text=None, def manage_addPageTemplate(self, id, title=None, text=None,
...@@ -368,16 +375,7 @@ def manage_addPageTemplate(self, id, title=None, text=None, ...@@ -368,16 +375,7 @@ def manage_addPageTemplate(self, id, title=None, text=None,
REQUEST.RESPONSE.redirect(u+'/manage_main') REQUEST.RESPONSE.redirect(u+'/manage_main')
return '' return ''
#manage_addPageTemplateForm = DTMLFile('dtml/ptAdd', globals())
def initialize(context): def initialize(context):
from PageTemplateFile import PageTemplateFile
manage_addPageTemplateForm = PageTemplateFile('www/ptAdd', globals())
_editForm = PageTemplateFile('www/ptEdit', globals())
ZopePageTemplate.manage = _editForm
ZopePageTemplate.manage_main = _editForm
ZopePageTemplate.pt_editForm = _editForm
_editForm._owner = None
context.registerClass( context.registerClass(
ZopePageTemplate, ZopePageTemplate,
permission='Add Page Templates', permission='Add Page Templates',
......
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