[Zope3-checkins] CVS: Zope3/src/zope/app/tests - setup.py:1.26 ztapi.py:1.8

Jim Fulton jim at zope.com
Sun Apr 18 12:01:04 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/tests
In directory cvs.zope.org:/tmp/cvs-serv12900/src/zope/app/tests

Modified Files:
	setup.py ztapi.py 
Log Message:
Changed way namespace handlers (handlers for traversing names of the
form "++namespace++name") are registered.  Now the are registered as
views and adapters.  When traversing a namespace-qualified view, a
request is sometimes provided.  When a request is provided, a view
will be used to traverse the name. Otherwise, an adapter is used.
handlers that don't care about the request are registered as both an
adapter and a view.

With this change, it's not possible to have content-specific
namespace-specific traversers.  Content objects can now define
specialized namespaces.


=== Zope3/src/zope/app/tests/setup.py 1.25 => 1.26 ===
--- Zope3/src/zope/app/tests/setup.py:1.25	Thu Apr 15 11:29:41 2004
+++ Zope3/src/zope/app/tests/setup.py	Sun Apr 18 12:00:32 2004
@@ -17,6 +17,7 @@
 """
 
 import zope.component
+import zope.interface
 from zope.app import zapi
 from zope.app.tests import ztapi
 from zope.interface import classImplements
@@ -49,7 +50,7 @@
 from zope.app.traversing.adapters import DefaultTraversable
 from zope.app.traversing.adapters import Traverser, RootPhysicallyLocatable
 from zope.app.location import LocationPhysicallyLocatable
-from zope.app.traversing.namespace import etc, provideNamespaceHandler
+from zope.app.traversing.namespace import etc
 
 def setUpTraversal():
     ztapi.provideAdapter(None, ITraverser, Traverser)
@@ -63,7 +64,8 @@
         IContainmentRoot, IPhysicallyLocatable, RootPhysicallyLocatable)
 
     # set up etc namespace
-    provideNamespaceHandler("etc", etc)
+    ztapi.provideAdapter(None, ITraversable, etc, name="etc")
+    ztapi.provideView(None, zope.interface.Interface, ITraversable, "etc", etc)
 
     ztapi.browserView(None, "absolute_url", AbsoluteURL)
     ztapi.browserView(IContainmentRoot, "absolute_url", SiteAbsoluteURL)


=== Zope3/src/zope/app/tests/ztapi.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/tests/ztapi.py:1.7	Mon Mar 22 19:23:12 2004
+++ Zope3/src/zope/app/tests/ztapi.py	Sun Apr 18 12:00:32 2004
@@ -19,6 +19,13 @@
 import zope.interface
 from zope.component.servicenames import Presentation, Adapters, Utilities
 from zope.publisher.browser import IBrowserRequest
+from zope.app.traversing.interfaces import ITraversable
+
+def provideView(for_, type, providing, name, factory, layer="default"):
+    s = zapi.getService(None, Presentation)
+    return s.provideView(for_, name, type, factory, layer,
+                         providing=providing)
+    
 
 def browserView(for_, name, factory, layer='default',
                 providing=zope.interface.Interface):
@@ -70,3 +77,7 @@
 def provideUtility(provided, component, name=''):
     s = zapi.getService(None, Utilities)
     s.provideUtility(provided, component, name)
+
+def provideNamespaceHandler(name, handler):
+    provideAdapter(None, ITraversable, handler, name=name)
+    provideView(None, zope.interface.Interface, ITraversable, name, handler)




More information about the Zope3-Checkins mailing list