[Checkins] SVN: Zope3/trunk/src/zope/app/ - ported fix for issue 574 from 3.3 branch

Christian Theune ct at gocept.com
Mon Aug 14 22:20:29 EDT 2006


Log message for revision 69499:
   - ported fix for issue 574 from 3.3 branch
  

Changed:
  U   Zope3/trunk/src/zope/app/generations/browser/managerdetails.pt
  U   Zope3/trunk/src/zope/app/homefolder/tests.py
  U   Zope3/trunk/src/zope/app/pagetemplate/configure.zcml
  U   Zope3/trunk/src/zope/app/pagetemplate/engine.py
  U   Zope3/trunk/src/zope/app/pagetemplate/tests/test_engine.py
  U   Zope3/trunk/src/zope/app/session/configure.zcml

-=-
Modified: Zope3/trunk/src/zope/app/generations/browser/managerdetails.pt
===================================================================
--- Zope3/trunk/src/zope/app/generations/browser/managerdetails.pt	2006-08-15 02:09:08 UTC (rev 69498)
+++ Zope3/trunk/src/zope/app/generations/browser/managerdetails.pt	2006-08-15 02:20:28 UTC (rev 69499)
@@ -1,6 +1,6 @@
 <html metal:use-macro="context/@@standard_macros/view" i18n:domain="zope">
 <head>
-<title metal:fill-slot="title">Manager Detials</title>
+<title metal:fill-slot="title">Manager Details</title>
 </head>
 <body>
 <div metal:fill-slot="body">

Modified: Zope3/trunk/src/zope/app/homefolder/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/homefolder/tests.py	2006-08-15 02:09:08 UTC (rev 69498)
+++ Zope3/trunk/src/zope/app/homefolder/tests.py	2006-08-15 02:20:28 UTC (rev 69499)
@@ -33,6 +33,9 @@
 from zope.app.homefolder.homefolder import HomeFolder, getHomeFolder
 from zope.app.homefolder.interfaces import IHomeFolder
 
+from zope.app.folder.folder import Folder
+from zope.app.folder.interfaces import IFolder
+from zope.security.checker import InterfaceChecker, defineChecker
 
 def homeFolderSetUp(test):
     placelesssetup.setUp()    
@@ -40,6 +43,7 @@
     setup.setUpTraversal()
 
     classImplements(File, IAttributeAnnotatable)
+
     ztapi.provideAdapter(IAnnotatable, IPrincipalRoleManager,
                          AnnotationPrincipalRoleManager)
     ztapi.provideAdapter(IPrincipal, IHomeFolder,
@@ -47,6 +51,9 @@
     ztapi.provideAdapter(IPrincipal, IPathAdapter,
                          getHomeFolder,
                          name="homefolder")
+    
+    testChecker = InterfaceChecker(IFolder)
+    defineChecker(Folder, testChecker)
 
     
 def test_suite():

Modified: Zope3/trunk/src/zope/app/pagetemplate/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/configure.zcml	2006-08-15 02:09:08 UTC (rev 69498)
+++ Zope3/trunk/src/zope/app/pagetemplate/configure.zcml	2006-08-15 02:20:28 UTC (rev 69499)
@@ -11,12 +11,21 @@
       name="zope" 
       />
 
+  <class class=".talesapi.ZopeTalesAPI">
+    <allow interface="zope.tales.interfaces.ITALESFunctionNamespace"/>
+    <allow attributes="title description created modified name title_or_name size"/>
+  </class>
+
   <adapter
       for="*"
       provides="zope.traversing.interfaces.IPathAdapter"
       factory=".urlquote.URLQuote"
       name="url"/> 
 
+  <class class=".urlquote.URLQuote">
+    <allow attributes="quote quote_plus unquote unquote_plus"/>
+  </class> 
+
  <class class="zope.tales.tales.Iterator">
     <allow interface="zope.tales.interfaces.ITALESIterator" />
  </class>

Modified: Zope3/trunk/src/zope/app/pagetemplate/engine.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/engine.py	2006-08-15 02:09:08 UTC (rev 69498)
+++ Zope3/trunk/src/zope/app/pagetemplate/engine.py	2006-08-15 02:20:28 UTC (rev 69499)
@@ -249,7 +249,34 @@
         return namespace
 
 
-class ZopeEngine(ExpressionEngine):
+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
@@ -355,33 +382,12 @@
 
     """
 
-    _create_context = ZopeContext
+    def getFunctionNamespace(self, namespacename):
+        """ Returns the function namespace """
+        return ProxyFactory(
+            super(ZopeEngine, self).getFunctionNamespace(namespacename))
 
-    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 TrustedZopeEngine(ZopeEngine):
+class TrustedZopeEngine(ZopeBaseEngine):
     """Trusted expression engine.
 
     This engine allows modules to be imported::

Modified: Zope3/trunk/src/zope/app/pagetemplate/tests/test_engine.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/tests/test_engine.py	2006-08-15 02:09:08 UTC (rev 69498)
+++ Zope3/trunk/src/zope/app/pagetemplate/tests/test_engine.py	2006-08-15 02:20:28 UTC (rev 69499)
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2004 Zope Corporation and Contributors.
+# Copyright (c) 2004-2006 Zope Corporation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -18,9 +18,38 @@
 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():
-    return DocTestSuite('zope.app.pagetemplate.engine')
+    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')
-

Modified: Zope3/trunk/src/zope/app/session/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/session/configure.zcml	2006-08-15 02:09:08 UTC (rev 69498)
+++ Zope3/trunk/src/zope/app/session/configure.zcml	2006-08-15 02:20:28 UTC (rev 69499)
@@ -23,7 +23,6 @@
       provides="zope.traversing.interfaces.IPathAdapter"
       factory=".session.Session"
       name="session"
-      permission="zope.Public"
       />
 
   <class class=".session.Session">



More information about the Checkins mailing list