diff options
author | Albertas Agejevas <alga@pov.lt> | 2013-02-22 16:26:24 +0000 |
---|---|---|
committer | Albertas Agejevas <alga@pov.lt> | 2013-02-22 16:26:24 +0000 |
commit | 06c4132348e3daae1150c4e066604446aac4e949 (patch) | |
tree | 5b364fe65d2d48a7a21e5f293654415d43855572 | |
parent | 53cef712e18d1cd0eb43c3229ad394211f929f3d (diff) | |
download | zope-pagetemplate-06c4132348e3daae1150c4e066604446aac4e949.tar.gz |
Switch to zope.untrustedpython, make it an extra.
-rw-r--r-- | buildout.cfg | 6 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | src/zope/pagetemplate/engine.py | 11 | ||||
-rw-r--r-- | src/zope/pagetemplate/tests/test_engine.py | 4 |
4 files changed, 16 insertions, 7 deletions
diff --git a/buildout.cfg b/buildout.cfg index 45873e5..83873d2 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -4,11 +4,11 @@ parts = py test testcompat coverage-test coverage-report [test] recipe = zc.recipe.testrunner -eggs = zope.pagetemplate [test] +eggs = zope.pagetemplate [test, untrusted] [testcompat] recipe = zc.recipe.testrunner -eggs = zope.pagetemplate [test] +eggs = zope.pagetemplate [test, untrusted] z3c.pt z3c.ptcompat Chameleon @@ -20,7 +20,7 @@ interpreter = py [coverage-test] recipe = zc.recipe.testrunner -eggs = zope.pagetemplate [test] +eggs = zope.pagetemplate [test, untrusted] defaults = ['--coverage', '../../coverage'] [coverage-report] @@ -101,11 +101,11 @@ setup(name='zope.pagetemplate', namespace_packages=['zope'], extras_require=dict( test=TESTS_REQUIRE, + untrusted=['zope.untrustedpython'], ), install_requires=['setuptools', 'zope.interface', 'zope.component', - 'zope.security [untrustedpython]', 'zope.tales', 'zope.tal', 'zope.i18n', 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 |