summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbertas Agejevas <alga@pov.lt>2013-02-22 16:26:24 +0000
committerAlbertas Agejevas <alga@pov.lt>2013-02-22 16:26:24 +0000
commit06c4132348e3daae1150c4e066604446aac4e949 (patch)
tree5b364fe65d2d48a7a21e5f293654415d43855572 /src
parent53cef712e18d1cd0eb43c3229ad394211f929f3d (diff)
downloadzope-pagetemplate-06c4132348e3daae1150c4e066604446aac4e949.tar.gz
Switch to zope.untrustedpython, make it an extra.
Diffstat (limited to 'src')
-rw-r--r--src/zope/pagetemplate/engine.py11
-rw-r--r--src/zope/pagetemplate/tests/test_engine.py4
2 files changed, 12 insertions, 3 deletions
diff --git a/src/zope/pagetemplate/engine.py b/src/zope/pagetemplate/engine.py
index 3e68c46..6974dfb 100644
--- a/src/zope/pagetemplate/engine.py
+++ b/src/zope/pagetemplate/engine.py
@@ -25,11 +25,16 @@ from zope.component.interfaces import ComponentLookupError
from zope.traversing.interfaces import IPathAdapter, ITraversable
from zope.traversing.interfaces import TraversalError
from zope.traversing.adapters import traversePathElement
-from zope.security.untrustedpython import rcompile
from zope.security.proxy import ProxyFactory, removeSecurityProxy
-from zope.security.untrustedpython.builtins import SafeBuiltins
from zope.i18n import translate
+try:
+ from zope.untrustedpython import rcompile
+ from zope.untrustedpython.builtins import SafeBuiltins
+ HAVE_UNTRUSTED = True
+except ImportError:
+ HAVE_UNTRUSTED = False
+
from zope.tales.expressions import PathExpr, StringExpr, NotExpr, DeferExpr
from zope.tales.expressions import SimpleModuleImporter
from zope.tales.pythonexpr import PythonExpr
@@ -98,6 +103,8 @@ class ZopePythonExpr(PythonExpr):
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."""
diff --git a/src/zope/pagetemplate/tests/test_engine.py b/src/zope/pagetemplate/tests/test_engine.py
index dafeabe..761bce9 100644
--- a/src/zope/pagetemplate/tests/test_engine.py
+++ b/src/zope/pagetemplate/tests/test_engine.py
@@ -14,6 +14,7 @@
"""Doc tests for the pagetemplate's 'engine' module
"""
import unittest
+import zope.pagetemplate.engine
class DummyNamespace(object):
@@ -84,7 +85,8 @@ def test_suite():
suite = unittest.TestSuite()
suite.addTest(DocTestSuite('zope.pagetemplate.engine'))
suite.addTest(unittest.makeSuite(EngineTests))
- suite.addTest(unittest.makeSuite(ZopePythonExprTests))
+ if zope.pagetemplate.engine.HAVE_UNTRUSTED:
+ suite.addTest(unittest.makeSuite(ZopePythonExprTests))
return suite