[Zope3-checkins] CVS: Zope3/src/zope/app/publication - httpfactory.py:1.1 browser.py:1.5 http.py:1.3 xmlrpc.py:1.4 zopepublication.py:1.15 configure.zcml:NONE
Jim Fulton
jim@zope.com
Fri, 7 Feb 2003 11:00:14 -0500
Update of /cvs-repository/Zope3/src/zope/app/publication
In directory cvs.zope.org:/tmp/cvs-serv24670/src/zope/app/publication
Modified Files:
browser.py http.py xmlrpc.py zopepublication.py
Added Files:
httpfactory.py
Removed Files:
configure.zcml
Log Message:
Implemented HTTP PUT. Do do this, I had to:
- Implement working HTTP publication, request, response
- Change the server setup so that rather than having a Browser
server and an XML-RPC server, there is an HTTP server that
uses:
o Browser request, response, and publication for browser (GET, POST,
and HEAD) requests,
o XMLRPC request, response, and publication for xml-rpc (POST
w content-type=='text/xml') requests,
o HTTP request, response, and publication for all other HTTP requests.
XML-RPC now runs on the same port, 8080, as browser requests.
- Implemented HEAD.
- Implemented some simple PUT views that use the
file-system-reprentation adapter framework. (This is the replacement
for VFS that is also used by FTP and may be used as part of
file-system synchronization.)
=== Added File Zope3/src/zope/app/publication/httpfactory.py ===
##############################################################################
#
# 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.
#
##############################################################################
"""
$Id: httpfactory.py,v 1.1 2003/02/07 15:59:41 jim Exp $
"""
from zope.publisher.http import HTTPRequest
from zope.publisher.browser import BrowserRequest
from zope.publisher.xmlrpc import XMLRPCRequest
from zope.app.interfaces.startup import IPublicationRequestFactoryFactory
from zope.app.interfaces.startup import IPublicationRequestFactory
from zope.app.publication.http import HTTPPublication
from zope.app.publication.browser import BrowserPublication
from zope.app.publication.xmlrpc import XMLRPCPublication
__implements__ = IPublicationRequestFactoryFactory
__metaclass__ = type
_browser_methods = 'GET', 'POST', 'HEAD'
class HTTPPublicationRequestFactory:
__implements__ = IPublicationRequestFactory
def __init__(self, db):
'See IRequestFactory'
self._http = HTTPPublication(db)
self._brower = BrowserPublication(db)
self._xmlrpc = XMLRPCPublication(db)
def __call__(self, input_stream, output_steam, env):
'See IRequestFactory'
method = env.get('REQUEST_METHOD', 'GET').upper()
if method in _browser_methods:
if (method == 'POST' and
env.get('CONTENT_TYPE', '').startswith('text/xml')
):
request = XMLRPCRequest(input_stream, output_steam, env)
request.setPublication(self._xmlrpc)
else:
request = BrowserRequest(input_stream, output_steam, env)
request.setPublication(self._brower)
else:
request = HTTPRequest(input_stream, output_steam, env)
request.setPublication(self._http)
return request
realize = HTTPPublicationRequestFactory
=== Zope3/src/zope/app/publication/browser.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/publication/browser.py:1.4 Tue Dec 31 13:26:57 2002
+++ Zope3/src/zope/app/publication/browser.py Fri Feb 7 10:59:41 2003
@@ -19,7 +19,7 @@
from zope.app.publication.publicationtraverse \
import PublicationTraverser as PublicationTraverser_
-from zope.app.publication.http import ZopeHTTPPublication
+from zope.app.publication.zopepublication import ZopePublication
from zope.component import queryAdapter, queryView
from zope.proxy.context import ContextWrapper
from zope.proxy.introspection import removeAllProxies
@@ -43,7 +43,7 @@
ob = self.traversePath(request, ob, path)
-class BrowserPublication(ZopeHTTPPublication):
+class BrowserPublication(ZopePublication):
"""Web browser publication handling."""
def getDefaultTraversal(self, request, ob):
@@ -64,6 +64,11 @@
wrapped = ContextWrapper(ProxyFactory(r[0]), ob, name=None)
return (wrapped, r[1])
+
+ def afterCall(self, request):
+ super(BrowserPublication, self).afterCall(request)
+ if request.method == 'HEAD':
+ request.response.setBody('')
# For now, have a factory that returns a singleton
class PublicationFactory:
=== Zope3/src/zope/app/publication/http.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/publication/http.py:1.2 Wed Dec 25 09:13:08 2002
+++ Zope3/src/zope/app/publication/http.py Fri Feb 7 10:59:41 2003
@@ -17,7 +17,13 @@
"""
from zope.app.publication.zopepublication import ZopePublication
+from zope.component import getView
+from zope.publisher.publish import mapply
-class ZopeHTTPPublication(ZopePublication):
+class HTTPPublication(ZopePublication):
"HTTP-specific support"
- # XXX do we need this?
+
+ def callObject(self, request, ob):
+ ob = getView(ob, request.method, request)
+ ob = getattr(ob, request.method)
+ return mapply(ob, request.getPositionalArguments(), request)
=== Zope3/src/zope/app/publication/xmlrpc.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/publication/xmlrpc.py:1.3 Tue Jan 14 15:26:05 2003
+++ Zope3/src/zope/app/publication/xmlrpc.py Fri Feb 7 10:59:41 2003
@@ -15,11 +15,12 @@
$Id$
"""
+
from zope.proxy.introspection import removeAllProxies
-from zope.app.publication.http import ZopeHTTPPublication
+from zope.app.publication.zopepublication import ZopePublication
from zope.component import queryView
-class XMLRPCPublication(ZopeHTTPPublication):
+class XMLRPCPublication(ZopePublication):
"""XML-RPC publication handling.
There is nothing special here right now.
=== Zope3/src/zope/app/publication/zopepublication.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/publication/zopepublication.py:1.14 Thu Feb 6 08:00:52 2003
+++ Zope3/src/zope/app/publication/zopepublication.py Fri Feb 7 10:59:41 2003
@@ -269,23 +269,6 @@
def _parameterSetskin(self, pname, pval, request):
request.setViewSkin(pval)
-class DebugPublication(object):
-
- class call_wrapper:
-
- def __init__(self, ob):
- self.__ob = ob
-
- def __getattr__(self, name):
- return getattr(self.__ob, name)
-
- def __call__(self, *args, **kw):
- self.__ob(*args, **kw)
-
- def callObject(self, request, ob):
- return mapply(self.call_wrapper(ob),
- request.getPositionalArguments(), request)
-
def tryToLogException(arg1, arg2=None):
if arg2 is None:
subsystem = 'SiteError'
=== Removed File Zope3/src/zope/app/publication/configure.zcml ===