[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server - IRequestFactory.py:1.1.2.1 PublisherServers.py:1.1.2.8.6.1

Jim Fulton jim@zope.com
Tue, 26 Mar 2002 12:59:54 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server
In directory cvs.zope.org:/tmp/cvs-serv20917/Zope/Server

Modified Files:
      Tag: Zope3-publisher-refactor-branch
	PublisherServers.py 
Added Files:
      Tag: Zope3-publisher-refactor-branch
	IRequestFactory.py 
Log Message:
Modified the server to use the new request factory API and got all the
unit tests to pass.


=== Added File Zope3/lib/python/Zope/Server/IRequestFactory.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
# 
##############################################################################
"""

Revision information:
$Id: IRequestFactory.py,v 1.1.2.1 2002/03/26 17:59:53 jim Exp $
"""

from Interface import Interface

class IRequestFactory:

    def __call__(input_stream, output_steam, environment):
        """Create a request object *with* a publication

        Factories that support multiple request/response/publication
        types may look at the environment (headers) or the stream to
        determine which request/response/publication to create.
        """


        


=== Zope3/lib/python/Zope/Server/PublisherServers.py 1.1.2.8 => 1.1.2.8.6.1 ===
         env = self.create_environment()
         instream = self.request_data.getBodyStream()
-        resp = HTTPResponse(server.response_payload, self, self)
-        req = HTTPRequest(server.request_payload, resp, instream, env)
-        publish(req)
+
+        request = server.request_factory(instream, self, env)
+        response = request.getResponse()
+        response.setHeaderOutput(self)
+        publish(request)
 
     def create_environment(self):
         request_data = self.request_data
@@ -105,8 +107,7 @@
 
     channel_class = PublisherHTTPChannel
     
-    def __init__(self, request_payload, response_payload, *args, **kw):
-        self.request_payload = request_payload
-        self.response_payload = response_payload
+    def __init__(self, request_factory, *args, **kw):
+        self.request_factory = request_factory
         HTTPServer.__init__(self, *args, **kw)