[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - Traversers.py:1.1.2.8

Jim Fulton jim@zope.com
Sun, 3 Feb 2002 18:28:05 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv26530

Modified Files:
      Tag: Zope-3x-branch
	Traversers.py 
Log Message:
Kapil Thangavelu

Changed browser_default to reflect new method semantics. Now just look
up a view name and return it's URI.


=== Zope3/lib/python/Zope/App/ZopePublication/Traversers.py 1.1.2.7 => 1.1.2.8 ===
 from Zope.Publisher.Exceptions import Unauthorized, NotFound, DebugError
 from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
-from Zope.ComponentArchitecture import getRequestView
+from Zope.ComponentArchitecture \
+     import getRequestView, getRequestDefaultViewName
 
 class DefaultTraverser:
     """
@@ -20,15 +21,18 @@
         self.target = target
 
     def browser_default(self, request):
+        #XXX: (hack), we really need this to be component
+        # specific. 
         ob = self.target
+
+        # if ob is not a component return 
+        if not hasattr(ob, '__implements__'):
+            return ob,()
         
-        # Use the default view.
-        p = getRequestView(ob, '', request , None)
-        if p is None:
-            return ob, ()
-        
-        r = p.browser_default(request)
-        return r
+        view_name = getRequestDefaultViewName(ob, request)
+
+        view_uri = "%s;view"%view_name
+        return self, (view_uri,)
 
     def browser_traverse(self, request, name):
         """ """
@@ -48,3 +52,4 @@
                 raise NotFound(ob, name, request)
 
         return subob
+