[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/Browser - Publication.py:1.1.2.3 __init__.py:1.1.6.1

Jim Fulton jim@zope.com
Tue, 26 Mar 2002 16:26:26 -0500


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

Added Files:
      Tag: Zope-3x-branch
	Publication.py __init__.py 
Log Message:
Merged the publication refactoring branch into the main branch.

Also renamed:

  browser_reaverse -> publishTraverse

  browser_default -> browserDefault



=== Zope3/lib/python/Zope/App/ZopePublication/Browser/Publication.py 1.1.2.2 => 1.1.2.3 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+# 
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+from Zope.App.ZopePublication.HTTP.Publication import ZopeHTTPPublication
+from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
+from Zope.ComponentArchitecture import getRequestView
+from Zope.ContextWrapper import Wrapper
+from Zope.App.Security.SecurityManagement import getSecurityManager
+
+
+class BrowserPublication(ZopeHTTPPublication):
+    """Web browser publication handling."""
+        
+    def getDefaultTraversal(self, request, ob):
+
+        r = ()
+
+        if IBrowserPublisher.isImplementedBy(ob):
+            r = ob.browserDefault(request)
+        else:
+            adapter = getRequestView(ob, '_traverse', request , None)
+            if adapter is not None:
+                r = adapter.browserDefault(request)
+            else:
+                return (ob, None)
+
+        if r[0] is ob: return r
+        
+        wrapped = Wrapper(r[0], ob, name=None)
+        getSecurityManager().validate(None, wrapped)
+        return (wrapped, r[1])
+
+# For now, have a factory that returns a singleton
+class PublicationFactory:
+
+    def __init__(self, db):
+        self.__pub = BrowserPublication(db)
+
+    def __call__(self):
+        return self.__pub
+


=== Added File Zope3/lib/python/Zope/App/ZopePublication/Browser/__init__.py ===