[Checkins] SVN: zope.app.pagetemplate/trunk/ Move ``engine`` module and testing machinery -> ``zope.pagetemplate``.

Tres Seaver tseaver at palladion.com
Mon May 25 15:53:19 EDT 2009


Log message for revision 100376:
  Move ``engine`` module and testing machinery -> ``zope.pagetemplate``.
  
  o Released in version 3.5.0 of that package.
  

Changed:
  U   zope.app.pagetemplate/trunk/CHANGES.txt
  U   zope.app.pagetemplate/trunk/setup.py
  U   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/configure.zcml
  D   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/engine.py
  U   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/metaconfigure.py
  U   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_directives.py
  D   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_engine.py
  D   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_zopepythonexpr.py
  D   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/trusted.py
  U   zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/viewpagetemplatefile.py

-=-
Modified: zope.app.pagetemplate/trunk/CHANGES.txt
===================================================================
--- zope.app.pagetemplate/trunk/CHANGES.txt	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/CHANGES.txt	2009-05-25 19:53:19 UTC (rev 100376)
@@ -2,12 +2,12 @@
  Changes
 =========
 
-3.6.1 (unreleased)
+3.7.0 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Moved the ``engine`` module and associated testing machinery to
+  ``zope.pagetemplate`` (version 3.5.0).
 
-
 3.6.0 (2009-05-18)
 ------------------
 

Modified: zope.app.pagetemplate/trunk/setup.py
===================================================================
--- zope.app.pagetemplate/trunk/setup.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/setup.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -4,7 +4,7 @@
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
-version = '3.6.1dev'
+version = '3.7.0dev'
 
 
 setup(name='zope.app.pagetemplate',
@@ -41,7 +41,7 @@
           'zope.i18n',
           'zope.i18nmessageid',
           'zope.interface',
-          'zope.pagetemplate',
+          'zope.pagetemplate>=3.5.0',
           'zope.publisher',
           'zope.schema',
           'zope.security [untrustedpython]',
@@ -56,7 +56,8 @@
           "test": ['zope.container',
                    'zope.app.testing',
                    'zope.app.securitypolicy',
-                   'zope.app.zcmlfiles'],
+                   'zope.app.zcmlfiles',
+                  ],
           },
       zip_safe=False,
       )

Modified: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/configure.zcml
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/configure.zcml	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/configure.zcml	2009-05-25 19:53:19 UTC (rev 100376)
@@ -30,16 +30,16 @@
     <allow interface="zope.tales.interfaces.ITALESIterator" />
  </class>
 
- <class class=".engine.ZopePathExpr">
+ <class class="zope.pagetemplate.engine.ZopePathExpr">
     <allow attributes="__call__" />
  </class>
- <class class=".engine.TrustedZopePathExpr">
+ <class class="zope.pagetemplate.engine.TrustedZopePathExpr">
     <allow attributes="__call__" />
  </class>
- <class class=".engine.ZopePythonExpr">
+ <class class="zope.pagetemplate.engine.ZopePythonExpr">
     <allow attributes="__call__" />
  </class>
- <class class=".engine.PythonExpr">
+ <class class="zope.pagetemplate.engine.PythonExpr">
     <allow attributes="__call__" />
  </class>
 

Deleted: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/engine.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/engine.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/engine.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -1,478 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
-##############################################################################
-"""Expression engine configuration and registration.
-
-Each expression engine can have its own expression types and base names.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import sys
-
-from zope import component
-from zope.interface import implements
-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
-
-from zope.tales.expressions import PathExpr, StringExpr, NotExpr, DeferExpr
-from zope.tales.expressions import SimpleModuleImporter
-from zope.tales.pythonexpr import PythonExpr
-from zope.tales.tales import ExpressionEngine, Context
-
-from i18n import ZopeMessageFactory as _
-
-class InlineCodeError(Exception):
-    pass
-
-class ZopeTraverser(object):
-
-    def __init__(self, proxify=None):
-        if proxify is None:
-            self.proxify = lambda x: x
-        else:
-            self.proxify = proxify
-
-    def __call__(self, object, path_items, econtext):
-        """Traverses a sequence of names, first trying attributes then items.
-        """
-        request = getattr(econtext, 'request', None)
-        path_items = list(path_items)
-        path_items.reverse()
-
-        while path_items:
-            name = path_items.pop()
-            
-            # special-case dicts for performance reasons        
-            if getattr(object, '__class__', None) == dict:
-                object = object[name]
-            else:
-                object = traversePathElement(object, name, path_items,
-                                             request=request)
-            object = self.proxify(object)
-        return object
-
-zopeTraverser = ZopeTraverser(ProxyFactory)
-
-class ZopePathExpr(PathExpr):
-
-    def __init__(self, name, expr, engine):
-        super(ZopePathExpr, self).__init__(name, expr, engine, zopeTraverser)
-
-trustedZopeTraverser = ZopeTraverser()
-
-class TrustedZopePathExpr(PathExpr):
-
-    def __init__(self, name, expr, engine):
-        super(TrustedZopePathExpr, self).__init__(name, expr, engine,
-                                                  trustedZopeTraverser)
-
-
-# Create a version of the restricted built-ins that uses a safe
-# version of getattr() that wraps values in security proxies where
-# appropriate:
-
-
-class ZopePythonExpr(PythonExpr):
-
-    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')
-
-
-class ZopeContextBase(Context):
-    """Base class for both trusted and untrusted evaluation contexts."""
-
-    def translate(self, msgid, domain=None, mapping=None, default=None):
-        return translate(msgid, domain, mapping,
-                         context=self.request, default=default)
-
-    evaluateInlineCode = False
-
-    def evaluateCode(self, lang, code):
-        if not self.evaluateInlineCode:
-            raise InlineCodeError(
-                  _('Inline Code Evaluation is deactivated, which means that '
-                    'you cannot have inline code snippets in your Page '
-                    'Template. Activate Inline Code Evaluation and try again.'))
-
-        # TODO This is only needed when self.evaluateInlineCode is true,
-        # so should only be needed for zope.app.pythonpage.
-        from zope.app.interpreter.interfaces import IInterpreter
-        interpreter = component.queryUtility(IInterpreter, lang)
-        if interpreter is None:
-            error = _('No interpreter named "${lang_name}" was found.',
-                      mapping={'lang_name': lang})
-            raise InlineCodeError(error)
-
-        globals = self.vars.copy()
-        result = interpreter.evaluateRawCode(code, globals)
-        # Add possibly new global variables.
-        old_names = self.vars.keys()
-        for name, value in globals.items():
-            if name not in old_names:
-                self.setGlobal(name, value)
-        return result
-
-
-class ZopeContext(ZopeContextBase):
-    """Evaluation context for untrusted programs."""
-
-    def evaluateMacro(self, expr):
-        """evaluateMacro gets security-proxied macro programs when this
-        is run with the zopeTraverser, and in other untrusted
-        situations. This will cause evaluation to fail in
-        zope.tal.talinterpreter, which knows nothing of security proxies. 
-        Therefore, this method removes any proxy from the evaluated
-        expression.
-        
-        >>> output = [('version', 'xxx'), ('mode', 'html'), ('other', 'things')]
-        >>> def expression(context):
-        ...     return ProxyFactory(output)
-        ...
-        >>> zc = ZopeContext(ExpressionEngine, {})
-        >>> out = zc.evaluateMacro(expression)
-        >>> type(out)
-        <type 'list'>
-
-        The method does some trivial checking to make sure we are getting
-        back a macro like we expect: it must be a sequence of sequences, in
-        which the first sequence must start with 'version', and the second
-        must start with 'mode'.
-
-        >>> del output[0]
-        >>> zc.evaluateMacro(expression) # doctest: +ELLIPSIS
-        Traceback (most recent call last):
-        ...
-        ValueError: ('unexpected result from macro evaluation.', ...)
-
-        >>> del output[:]
-        >>> zc.evaluateMacro(expression) # doctest: +ELLIPSIS
-        Traceback (most recent call last):
-        ...
-        ValueError: ('unexpected result from macro evaluation.', ...)
-
-        >>> output = None
-        >>> zc.evaluateMacro(expression) # doctest: +ELLIPSIS
-        Traceback (most recent call last):
-        ...
-        ValueError: ('unexpected result from macro evaluation.', ...)
-        """
-        macro = removeSecurityProxy(Context.evaluateMacro(self, expr))
-        # we'll do some basic checks that it is the sort of thing we expect
-        problem = False
-        try:
-            problem = macro[0][0] != 'version' or macro[1][0] != 'mode'
-        except (TypeError, IndexError):
-            problem = True
-        if problem:
-            raise ValueError('unexpected result from macro evaluation.', macro)
-        return macro
-
-    def setContext(self, name, value):
-        # Hook to allow subclasses to do things like adding security proxies
-        Context.setContext(self, name, ProxyFactory(value))
-
-
-class TrustedZopeContext(ZopeContextBase):
-    """Evaluation context for trusted programs."""
-
-
-class AdapterNamespaces(object):
-    """Simulate tales function namespaces with adapter lookup.
-
-    When we are asked for a namespace, we return an object that
-    actually computes an adapter when called:
-
-    To demonstrate this, we need to register an adapter:
-
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
-      >>> setUp()
-      >>> from zope.app.testing import ztapi
-      >>> def adapter1(ob):
-      ...     return 1
-      >>> ztapi.provideAdapter(None, IPathAdapter, adapter1, 'a1')
-
-    Now, with this adapter in place, we can try out the namespaces:
-
-      >>> ob = object()
-      >>> namespaces = AdapterNamespaces()
-      >>> namespace = namespaces['a1']
-      >>> namespace(ob)
-      1
-      >>> namespace = namespaces['a2']
-      >>> namespace(ob)
-      Traceback (most recent call last):
-      ...
-      KeyError: 'a2'
-
-
-    Cleanup:
-
-      >>> tearDown()
-    """
-
-    def __init__(self):
-        self.namespaces = {}
-
-    def __getitem__(self, name):
-        namespace = self.namespaces.get(name)
-        if namespace is None:
-            def namespace(object):
-                try:
-                    return component.getAdapter(object, IPathAdapter, name)
-                except ComponentLookupError:
-                    raise KeyError(name)
-
-            self.namespaces[name] = namespace
-        return namespace
-
-
-class ZopeBaseEngine(ExpressionEngine):
-
-    _create_context = ZopeContext
-
-    def __init__(self):
-        ExpressionEngine.__init__(self)
-        self.namespaces = AdapterNamespaces()
-
-    def getContext(self, __namespace=None, **namespace):
-        if __namespace:
-            if namespace:
-                namespace.update(__namespace)
-            else:
-                namespace = __namespace
-
-        context = self._create_context(self, namespace)
-
-        # Put request into context so path traversal can find it
-        if 'request' in namespace:
-            context.request = namespace['request']
-
-        # Put context into context so path traversal can find it
-        if 'context' in namespace:
-            context.context = namespace['context']
-
-        return context
-
-class ZopeEngine(ZopeBaseEngine):
-    """Untrusted expression engine.
-
-    This engine does not allow modules to be imported; only modules
-    already available may be accessed::
-
-      >>> modname = 'zope.app.pagetemplate.tests.trusted'
-      >>> engine = _Engine()
-      >>> context = engine.getContext(engine.getBaseNames())
-
-      >>> modname in sys.modules
-      False
-      >>> context.evaluate('modules/' + modname)
-      Traceback (most recent call last):
-        ...
-      KeyError: 'zope.app.pagetemplate.tests.trusted'
-
-    (The use of ``KeyError`` is an unfortunate implementation detail; I
-    think this should be a ``TraversalError``.)
-
-    Modules which have already been imported by trusted code are
-    available, wrapped in security proxies::
-
-      >>> m = context.evaluate('modules/sys')
-      >>> m.__name__
-      'sys'
-      >>> m._getframe
-      Traceback (most recent call last):
-        ...
-      ForbiddenAttribute: ('_getframe', <module 'sys' (built-in)>)
-
-    The results of Python expressions evaluated by this engine are
-    wrapped in security proxies::
-
-      >>> r = context.evaluate('python: {12: object()}.values')
-      >>> type(r)
-      <type 'zope.security._proxy._Proxy'>
-      >>> r = context.evaluate('python: {12: object()}.values()[0].__class__')
-      >>> type(r)
-      <type 'zope.security._proxy._Proxy'>
-
-    General path expressions provide objects that are wrapped in
-    security proxies as well::
-
-      >>> from zope.container.sample import SampleContainer
-      >>> from zope.app.testing.placelesssetup import setUp, tearDown
-      >>> from zope.security.checker import NamesChecker, defineChecker
-
-      >>> class Container(SampleContainer):
-      ...     implements(ITraversable)
-      ...     def traverse(self, name, further_path):
-      ...         return self[name]
-
-      >>> setUp()
-      >>> defineChecker(Container, NamesChecker(['traverse']))
-      >>> d = engine.getBaseNames()
-      >>> foo = Container()
-      >>> foo.__name__ = 'foo'
-      >>> d['foo'] = ProxyFactory(foo)
-      >>> foo['bar'] = bar = Container()
-      >>> bar.__name__ = 'bar'
-      >>> bar.__parent__ = foo
-      >>> bar['baz'] = baz = Container()
-      >>> baz.__name__ = 'baz'
-      >>> baz.__parent__ = bar
-      >>> context = engine.getContext(d)
-
-      >>> o1 = context.evaluate('foo/bar')
-      >>> o1.__name__
-      'bar'
-      >>> type(o1)
-      <type 'zope.security._proxy._Proxy'>
-
-      >>> o2 = context.evaluate('foo/bar/baz')
-      >>> o2.__name__
-      'baz'
-      >>> type(o2)
-      <type 'zope.security._proxy._Proxy'>
-      >>> o3 = o2.__parent__
-      >>> type(o3)
-      <type 'zope.security._proxy._Proxy'>
-      >>> o1 == o3
-      True
-
-      >>> o1 is o2
-      False
-
-    Note that this engine special-cases dicts during path traversal:
-    it traverses only to their items, but not to their attributes
-    (e.g. methods on dicts), because of performance reasons:
-
-      >>> d = engine.getBaseNames()
-      >>> d['adict'] = {'items': 123}
-      >>> d['anotherdict'] = {}
-      >>> context = engine.getContext(d)
-      >>> context.evaluate('adict/items')
-      123
-      >>> context.evaluate('anotherdict/keys')
-      Traceback (most recent call last):
-        ...
-      KeyError: 'keys'
-
-      >>> tearDown()
-
-    """
-
-    def getFunctionNamespace(self, namespacename):
-        """ Returns the function namespace """
-        return ProxyFactory(
-            super(ZopeEngine, self).getFunctionNamespace(namespacename))
-
-class TrustedZopeEngine(ZopeBaseEngine):
-    """Trusted expression engine.
-
-    This engine allows modules to be imported::
-
-      >>> modname = 'zope.app.pagetemplate.tests.trusted'
-      >>> engine = _TrustedEngine()
-      >>> context = engine.getContext(engine.getBaseNames())
-
-      >>> modname in sys.modules
-      False
-      >>> m = context.evaluate('modules/' + modname)
-      >>> m.__name__ == modname
-      True
-      >>> modname in sys.modules
-      True
-
-    Since this is trusted code, we can look at whatever is in the
-    module, not just __name__ or what's declared in a security
-    assertion::
-
-      >>> m.x
-      42
-
-    Clean up after ourselves::
-
-      >>> del sys.modules[modname]
-
-    """
-
-    _create_context = TrustedZopeContext
-
-
-class TraversableModuleImporter(SimpleModuleImporter):
-
-    implements(ITraversable)
-
-    def traverse(self, name, further_path):
-        try:
-            return self[name]
-        except KeyError:
-            raise TraversalError(self, name)
-
-
-def _Engine(engine=None):
-    if engine is None:
-        engine = ZopeEngine()
-    engine = _create_base_engine(engine, ZopePathExpr)
-    engine.registerType('python', ZopePythonExpr)
-
-    # Using a proxy around sys.modules allows page templates to use
-    # modules for which security declarations have been made, but
-    # disallows execution of any import-time code for modules, which
-    # should not be allowed to happen during rendering.
-    engine.registerBaseName('modules', ProxyFactory(sys.modules))
-
-    return engine
-
-def _TrustedEngine(engine=None):
-    if engine is None:
-        engine = TrustedZopeEngine()
-    engine = _create_base_engine(engine, TrustedZopePathExpr)
-    engine.registerType('python', PythonExpr)
-    engine.registerBaseName('modules', TraversableModuleImporter())
-    return engine
-
-def _create_base_engine(engine, pathtype):
-    for pt in pathtype._default_type_names:
-        engine.registerType(pt, pathtype)
-    engine.registerType('string', StringExpr)
-    engine.registerType('not', NotExpr)
-    engine.registerType('defer', DeferExpr)
-    return engine
-
-
-Engine = _Engine()
-TrustedEngine = _TrustedEngine()
-
-
-class AppPT(object):
-
-    def pt_getEngine(self):
-        return Engine
-
-
-class TrustedAppPT(object):
-
-    def pt_getEngine(self):
-        return TrustedEngine

Modified: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/metaconfigure.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/metaconfigure.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/metaconfigure.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -18,10 +18,12 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.app.pagetemplate.engine import Engine, _Engine
-from zope.app.pagetemplate.engine import TrustedEngine, _TrustedEngine
+from zope.configuration.fields import GlobalObject
 from zope.interface import Interface
-from zope.configuration.fields import GlobalObject
+from zope.pagetemplate.engine import Engine
+from zope.pagetemplate.engine import _Engine
+from zope.pagetemplate.engine import TrustedEngine
+from zope.pagetemplate.engine import _TrustedEngine
 from zope.schema import TextLine
 
 class IExpressionTypeDirective(Interface):

Modified: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_directives.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_directives.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_directives.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -16,13 +16,8 @@
 $Id$
 """
 import unittest
-from cStringIO import StringIO
 
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
-
-import zope.app.pagetemplate
 from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.pagetemplate.engine import Engine
 
 template = """<configure 
    xmlns='http://namespaces.zope.org/zope'
@@ -37,10 +32,15 @@
 class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
+        from zope.configuration.xmlconfig import XMLConfig
+        import zope.app.pagetemplate
         super(Test, self).setUp()
         XMLConfig('meta.zcml', zope.app.pagetemplate)()
 
     def testExpressionType(self):
+        from cStringIO import StringIO
+        from zope.configuration.xmlconfig import xmlconfig
+        from zope.pagetemplate.engine import Engine
         xmlconfig(StringIO(template % (
             """
             <tales:expressiontype

Deleted: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_engine.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_engine.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_engine.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -1,55 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004-2006 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Doc tests for the pagetemplate's 'engine' module
-
-$Id$
-"""
-import unittest
-from zope.testing.doctestunit import DocTestSuite
-
-import zope.component
-from zope.app.pagetemplate.engine import _Engine
-from zope.proxy import isProxy
-from zope.traversing.interfaces import IPathAdapter
-
-class DummyNamespace(object):
-
-    def __init__(self, context):
-        self.context = context
-
-class EngineTests(unittest.TestCase):
-
-    def setUp(self):
-        gsm = zope.component.getGlobalSiteManager()
-        gsm.registerAdapter(DummyNamespace, required=(), provided=IPathAdapter, name='test')
-
-    def tearDown(self):
-        gsm = zope.component.getGlobalSiteManager()
-        gsm.unregisterAdapter(DummyNamespace, required=(), provided=IPathAdapter, name='test')
-
-    def test_issue574(self):
-        engine = _Engine()
-        namespace = engine.getFunctionNamespace('test')
-        self.failUnless(isProxy(namespace))
-
-
-def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(DocTestSuite('zope.app.pagetemplate.engine'))
-    suite.addTest(unittest.makeSuite(EngineTests))
-    return suite
-
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

Deleted: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_zopepythonexpr.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_zopepythonexpr.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/test_zopepythonexpr.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -1,54 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
-##############################################################################
-"""Zope Python Expression Tests
-
-$Id$
-"""
-from unittest import TestCase, main, makeSuite
-from zope.testing.cleanup import CleanUp
-
-class Engine(object):
-
-    def getTypes(self):
-        return {}
-
-class Context(object):
-
-    _engine = Engine()
-
-    def __init__(self, **kw):
-        self.vars = kw
-
-class Test(CleanUp, TestCase):
-
-    def test(self):
-        from zope.app.pagetemplate.engine import ZopePythonExpr
-        from zope.security.interfaces import Forbidden
-
-        expr = ZopePythonExpr('python', 'max(a,b)', Engine())
-        self.assertEqual(expr(Context(a=1, b=2)), 2)
-        expr = ZopePythonExpr(
-            'python', '__import__("sys").__name__', Engine())
-        self.assertEqual(expr(Context()), 'sys')
-        expr = ZopePythonExpr('python', '__import__("sys").exit',
-                              Engine())
-        self.assertRaises(Forbidden, expr, Context())
-        expr = ZopePythonExpr('python', 'open("x", "w")', Engine())
-        self.assertRaises(NameError, expr, Context())
-
-def test_suite():
-    return makeSuite(Test)
-
-if __name__=='__main__':
-    main(defaultTest='test_suite')

Deleted: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/trusted.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/trusted.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/tests/trusted.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -1,22 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Sample of a module imported by a trusted module.
-
-This module won't be imported by an untrusted template using a
-path:modules/... expression.
-
-$Id$
-"""
-
-x = 42

Modified: zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/viewpagetemplatefile.py
===================================================================
--- zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/viewpagetemplatefile.py	2009-05-25 19:37:42 UTC (rev 100375)
+++ zope.app.pagetemplate/trunk/src/zope/app/pagetemplate/viewpagetemplatefile.py	2009-05-25 19:53:19 UTC (rev 100376)
@@ -19,7 +19,7 @@
 
 from zope.component import getMultiAdapter
 from zope.pagetemplate.pagetemplatefile import PageTemplateFile
-from zope.app.pagetemplate.engine import TrustedAppPT
+from zope.pagetemplate.engine import TrustedAppPT
 
 class ViewPageTemplateFile(TrustedAppPT, PageTemplateFile):
     """Page Templates used as methods of views defined as Python classes.



More information about the Checkins mailing list