[Checkins] SVN: zope.app.publication/trunk/ Use zope:adpater ZCML directive instead of zope:view.

Baiju M baiju.m.mail at gmail.com
Sun Apr 5 18:49:20 EDT 2009


Log message for revision 98900:
  Use zope:adpater ZCML directive instead of zope:view.
  This avoid dependency on zope.app.component
  

Changed:
  U   zope.app.publication/trunk/CHANGES.txt
  U   zope.app.publication/trunk/src/zope/app/publication/configure.zcml
  A   zope.app.publication/trunk/src/zope/app/publication/tests/ftest_zcml_dependencies.zcml
  A   zope.app.publication/trunk/src/zope/app/publication/tests/test_dependencies.py

-=-
Modified: zope.app.publication/trunk/CHANGES.txt
===================================================================
--- zope.app.publication/trunk/CHANGES.txt	2009-04-05 20:16:30 UTC (rev 98899)
+++ zope.app.publication/trunk/CHANGES.txt	2009-04-05 22:49:20 UTC (rev 98900)
@@ -5,6 +5,9 @@
 3.5.4 (unreleased)
 ------------------
 
+- Use zope:adpater ZCML directive instead of zope:view.
+  This avoid dependency on zope.app.component
+
 - Update imports from zope.app.security to zope.authentication and
   zope.principalregistry.
 

Modified: zope.app.publication/trunk/src/zope/app/publication/configure.zcml
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/configure.zcml	2009-04-05 20:16:30 UTC (rev 98899)
+++ zope.app.publication/trunk/src/zope/app/publication/configure.zcml	2009-04-05 22:49:20 UTC (rev 98900)
@@ -3,13 +3,11 @@
     xmlns:browser="http://namespaces.zope.org/browser"
     >
 
-  <view
-      for="zope.interface.Interface"
-      type="zope.publisher.interfaces.browser.IBrowserRequest"
+  <adapter
+      for="* zope.publisher.interfaces.browser.IBrowserRequest"
       provides="zope.publisher.interfaces.browser.IBrowserPublisher"
       factory="zope.app.publication.traversers.SimpleComponentTraverser"
       permission="zope.Public"
-      allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
       />
 
   <adapter

Added: zope.app.publication/trunk/src/zope/app/publication/tests/ftest_zcml_dependencies.zcml
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/tests/ftest_zcml_dependencies.zcml	                        (rev 0)
+++ zope.app.publication/trunk/src/zope/app/publication/tests/ftest_zcml_dependencies.zcml	2009-04-05 22:49:20 UTC (rev 98900)
@@ -0,0 +1,10 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope">
+
+    <include package="zope.component" file="meta.zcml"/>
+    <include package="zope.app.publication" file="meta.zcml" />
+    <include package="zope.app.publisher.browser" file="meta.zcml" />
+
+    <include package="zope.app.publication"/>
+
+</configure>

Added: zope.app.publication/trunk/src/zope/app/publication/tests/test_dependencies.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/tests/test_dependencies.py	                        (rev 0)
+++ zope.app.publication/trunk/src/zope/app/publication/tests/test_dependencies.py	2009-04-05 22:49:20 UTC (rev 98900)
@@ -0,0 +1,39 @@
+import os
+import unittest
+
+from zope.interface import implements
+from zope.component import getMultiAdapter
+from zope.app.testing import functional
+from zope.publisher.browser import TestRequest
+
+from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.app.publication.traversers import SimpleComponentTraverser
+
+PublicationDependenciesLayer = functional.ZCMLLayer(
+    os.path.join(os.path.dirname(__file__), 'ftest_zcml_dependencies.zcml'),
+    __name__, 'PublicationDependenciesLayer', allow_teardown=True)
+
+
+class ZCMLDependencies(functional.BrowserTestCase):
+
+    def test_zcml_can_load_with_only_zope_component_meta(self):
+        # this is just an example.  It is supposed to show that the
+        # configure.zcml file has loaded successfully.
+
+        request = TestRequest()
+
+        sample = object()
+        res = getMultiAdapter(
+            (sample, request), IBrowserPublisher)
+        self.failUnless(isinstance(res, SimpleComponentTraverser))
+        self.failUnless(res.context is sample)
+
+def test_suite():
+    suite = unittest.TestSuite()
+    ZCMLDependencies.layer = PublicationDependenciesLayer
+    suite.addTest(unittest.makeSuite(ZCMLDependencies))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main()



More information about the Checkins mailing list