[Zope-Checkins] CVS: Zope3/lib/python/Zope/PageTemplate - PageTemplateFile.py:1.1.2.16
Shane Hathaway
shane@cvs.zope.org
Wed, 13 Mar 2002 22:59:01 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/PageTemplate
In directory cvs.zope.org:/tmp/cvs-serv11827
Modified Files:
Tag: Zope-3x-branch
PageTemplateFile.py
Log Message:
- Made use of new EngineConfig. You can use a specific expression engine
by passing the name to the constructor. Currently, the names available
are "restricted", "unrestricted", and "default".
- Removed dependency on SecureModuleImporter; the expression engine now
provides the "module" name as a base name.
- Anti-persistence is better implemented with a __getstate__() rather than
a __setstate__().
=== Zope3/lib/python/Zope/PageTemplate/PageTemplateFile.py 1.1.2.15 => 1.1.2.16 ===
from zLOG import LOG, ERROR, INFO
from ViewZPT import ViewZPT
-from Expressions import SecureModuleImporter
from Zope.Misc.package_home import package_home
DevelopmentMode = 1 # XXX should be imported from somewhere
@@ -38,9 +37,7 @@
_need__name__=1
_v_last_read=0
- _default_bindings = {'name_subpath': 'traverse_subpath'}
-
- def __init__(self, filename, _prefix=None):
+ def __init__(self, filename, _prefix=None, engine_name=None):
if _prefix is None:
_prefix = sys._getframe(1).f_globals
if not isinstance(_prefix, str):
@@ -48,10 +45,12 @@
if not os.path.splitext(filename)[1]:
filename = filename + '.zpt'
self.filename = os.path.join(_prefix, filename)
+ if engine_name is not None:
+ # Explicitly choose an expression engine.
+ self._engine_name = engine_name
def pt_getContext(self, **keywords):
namespace = ViewZPT.pt_getContext(self, **keywords)
- namespace['modules'] = SecureModuleImporter
return namespace
def __call__(self, instance, REQUEST, *args, **kw):
@@ -84,7 +83,7 @@
RESPONSE.setHeader('Content-Type', self.content_type)
return self.read()
- def __setstate__(self, state):
+ def __getstate__(self):
raise StorageError, ("Instance of AntiPersistent class %s "
"cannot be stored." % self.__class__.__name__)