summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Gedminas <marius@gedmin.as>2013-03-15 20:18:54 +0200
committerMarius Gedminas <marius@gedmin.as>2013-03-15 20:22:10 +0200
commit12b2fdd92198d92507ca43bd52bfaf14c98c5a3c (patch)
treeed5436fc56dd35cc9098718e62e79568ab8d04b4
parent493db2669365076383e52ee7d48e72bb1afd7279 (diff)
downloadzope-pagetemplate-12b2fdd92198d92507ca43bd52bfaf14c98c5a3c.tar.gz
Make sure ZopePythonExpr and PythonExpr are separate classes
There are ZCML files out there (zope.app.pagetemplate) that want to define permissions for ZopePythonExpr and PythonExpr, and get conflicts if these are two names referring to the same class.
-rw-r--r--CHANGES.txt5
-rw-r--r--src/zope/pagetemplate/engine.py16
2 files changed, 11 insertions, 10 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index c76212f..cdc1d94 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,8 +5,9 @@ CHANGES
4.0.4 (unreleased)
------------------
-- Nothing changed yet.
-
+- Make sure ``ZopePythonExpr`` and ``PythonExpr`` are separate classes even
+ when ``zope.untrustedpython`` is not available. Fixes a ZCML conflict error
+ in ``zope.app.pagetemplate``.
4.0.3 (2013-02-28)
------------------
diff --git a/src/zope/pagetemplate/engine.py b/src/zope/pagetemplate/engine.py
index d74e137..99634fa 100644
--- a/src/zope/pagetemplate/engine.py
+++ b/src/zope/pagetemplate/engine.py
@@ -95,16 +95,16 @@ class TrustedZopePathExpr(PathExpr):
class ZopePythonExpr(PythonExpr):
- def __call__(self, econtext):
- __traceback_info__ = self.text
- vars = self._bind_used_names(econtext, SafeBuiltins)
- return eval(self._code, vars)
+ if HAVE_UNTRUSTED:
- def _compile(self, text, filename):
- return rcompile.compile(text, filename, 'eval')
+ def __call__(self, econtext):
+ __traceback_info__ = self.text
+ vars = self._bind_used_names(econtext, SafeBuiltins)
+ return eval(self._code, vars)
+
+ def _compile(self, text, filename):
+ return rcompile.compile(text, filename, 'eval')
-if not HAVE_UNTRUSTED:
- ZopePythonExpr = PythonExpr
class ZopeContextBase(Context):
"""Base class for both trusted and untrusted evaluation contexts."""