[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/Browser - Debug.py:1.2 Publication.py:1.2 __init__.py:1.2
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 19:29:51 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/Browser
In directory cvs.zope.org:/tmp/cvs-serv20468/lib/python/Zope/App/ZopePublication/Browser
Added Files:
Debug.py Publication.py __init__.py
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.
=== Zope3/lib/python/Zope/App/ZopePublication/Browser/Debug.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Zope 3 debugger
+
+This is the first preliminary (add weasle words) cut at a zope debugger.
+
+$Id$
+"""
+__metaclass__ = type # All classes are new style when run with Python 2.2+
+
+from Zope.Publisher.Publish import publish as _publish
+from Zope.App.ZopePublication.Browser.Publication import BrowserPublication
+from ZODB.FileStorage import FileStorage
+from ZODB.DB import DB
+from Zope.Publisher.Browser.BrowserRequest import TestRequest
+from Zope.Configuration.xmlconfig import XMLConfig
+from cStringIO import StringIO
+import base64
+
+XMLConfig('../../site.zcml')()
+db= DB(FileStorage('../../Data.fs'))
+pub = BrowserPublication(db)
+
+def publish(path='/', stdin='', basic=None, **kw):
+ out = StringIO()
+ if type(stdin) is str:
+ stdin = StringIO(stdin)
+ env = {'PATH_INFO': path}
+ env.update(kw)
+
+ if basic:
+ env['HTTP_AUTHORIZATION']="Basic %s" % base64.encodestring(basic)
+
+ request = TestRequest(StringIO(''), StringIO(), env)
+ request.setPublication(pub)
+
+ _publish(request, 0)
=== Zope3/lib/python/Zope/App/ZopePublication/Browser/Publication.py 1.1 => 1.2 ===
+#
+# 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 queryView
+from Zope.Proxy.ContextWrapper import ContextWrapper
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+class BrowserPublication(ZopeHTTPPublication):
+ """Web browser publication handling."""
+
+ def getDefaultTraversal(self, request, ob):
+
+ r = ()
+
+ if IBrowserPublisher.isImplementedBy(removeAllProxies(ob)):
+ r = ob.browserDefault(request)
+ else:
+ adapter = queryView(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 = ContextWrapper(r[0], ob, name=None)
+ 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
+
=== Zope3/lib/python/Zope/App/ZopePublication/Browser/__init__.py 1.1 => 1.2 ===
+#
+# 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.
+#
+##############################################################################
+