[Checkins] SVN: zope.site/trunk/s - Updated code and tests to the getParent() API refactored between

Thomas Lotze tl at gocept.com
Wed Sep 23 13:02:42 EDT 2009


Log message for revision 104454:
  - Updated code and tests to the getParent() API refactored between
    zope.location and zope.traversing. This lifts the dependency on
    zope.traversing.
  - Need to configure zope.location now in order for nested local site
    managers to work. I tried to set up proper functional tests but failed,
    instead I let the test configure zope.location and isolate it within a
    layer of its own. Demoted zope.configuration to a test dependency.
  

Changed:
  U   zope.site/trunk/setup.py
  U   zope.site/trunk/src/zope/site/site.py
  U   zope.site/trunk/src/zope/site/site.txt
  U   zope.site/trunk/src/zope/site/tests/test_site.py

-=-
Modified: zope.site/trunk/setup.py
===================================================================
--- zope.site/trunk/setup.py	2009-09-23 16:34:27 UTC (rev 104453)
+++ zope.site/trunk/setup.py	2009-09-23 17:02:42 UTC (rev 104454)
@@ -57,6 +57,7 @@
       namespace_packages=['zope'],
       extras_require=dict(
           test=['zope.app.testing',
+                'zope.configuration',
                 'zope.copypastemove']),
       install_requires=[
           'setuptools',
@@ -64,12 +65,10 @@
           'zope.container',
           'zope.security',
           'zope.component>=3.6.0',
-          'zope.configuration',
           'zope.event',
           'zope.interface',
           'zope.lifecycleevent',
-          'zope.location>3.4.0b1',
-          'zope.traversing',
+          'zope.location>3.6.0',
           ],
       include_package_data = True,
       zip_safe = False,

Modified: zope.site/trunk/src/zope/site/site.py
===================================================================
--- zope.site/trunk/src/zope/site/site.py	2009-09-23 16:34:27 UTC (rev 104453)
+++ zope.site/trunk/src/zope/site/site.py	2009-09-23 17:02:42 UTC (rev 104454)
@@ -30,7 +30,6 @@
 import zope.component
 import zope.component.persistentregistry
 import zope.component.interfaces
-import zope.traversing.api
 import zope.location
 import zope.location.interfaces
 
@@ -96,7 +95,7 @@
             return None
 
         try:
-            site = zope.traversing.api.getParent(site)
+            site = zope.location.interfaces.ILocationInfo(site).getParent()
         except TypeError:
             # there was not enough context; probably run from a test
             return None

Modified: zope.site/trunk/src/zope/site/site.txt
===================================================================
--- zope.site/trunk/src/zope/site/site.txt	2009-09-23 16:34:27 UTC (rev 104453)
+++ zope.site/trunk/src/zope/site/site.txt	2009-09-23 17:02:42 UTC (rev 104454)
@@ -239,6 +239,17 @@
 really become interesting, once we have multiple sites. We can override other
 local configuration.
 
+This behaviour uses the notion of location, therefore we need to configure the
+zope.location package first:
+
+  >>> import zope.configuration.xmlconfig
+  >>> _  = zope.configuration.xmlconfig.string("""
+  ... <configure xmlns="http://namespaces.zope.org/zope">
+  ...   <include package="zope.component" file="meta.zcml"/>
+  ...   <include package="zope.location" />
+  ... </configure>
+  ... """)
+
 Let's now create a new folder called `folder11`, add it to `myfolder` and make
 it a site:
 

Modified: zope.site/trunk/src/zope/site/tests/test_site.py
===================================================================
--- zope.site/trunk/src/zope/site/tests/test_site.py	2009-09-23 16:34:27 UTC (rev 104453)
+++ zope.site/trunk/src/zope/site/tests/test_site.py	2009-09-23 17:02:42 UTC (rev 104454)
@@ -158,11 +158,24 @@
 def tearDown(test):
     testing.siteTearDown()
 
+
+class Layer(object):
+
+    @staticmethod
+    def setUp():
+        pass
+
+
 def test_suite():
+    site_suite = doctest.DocFileSuite('../site.txt',
+                                       setUp=setUp, tearDown=tearDown)
+    # XXX Isolate the site.txt tests within their own layer as they do some
+    # component registration.
+    site_suite.layer = Layer
+
     return unittest.TestSuite((
         doctest.DocTestSuite(),
         unittest.makeSuite(SiteManagerContainerTest),
-        doctest.DocFileSuite('../site.txt',
-                             setUp=setUp, tearDown=tearDown),
+        site_suite,
         ))
     



More information about the checkins mailing list