[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/tests - testPublisherServer.py:1.1.2.5.4.1
Jim Fulton
jim@zope.com
Tue, 26 Mar 2002 12:59:54 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server/tests
In directory cvs.zope.org:/tmp/cvs-serv20917/Zope/Server/tests
Modified Files:
Tag: Zope3-publisher-refactor-branch
testPublisherServer.py
Log Message:
Modified the server to use the new request factory API and got all the
unit tests to pass.
=== Zope3/lib/python/Zope/Server/tests/testPublisherServer.py 1.1.2.5 => 1.1.2.5.4.1 ===
from Zope.Server.TaskThreads import ThreadedTaskDispatcher
from Zope.Server.PublisherServers import PublisherHTTPServer
-from Zope.Publisher.HTTP.BrowserPayload import BrowserRequestPayload
-from Zope.Publisher.HTTP.BrowserPayload import BrowserResponsePayload
+from Zope.Publisher.Browser.BrowserRequest import BrowserRequest
+
from Zope.Publisher.DefaultPublication import DefaultPublication
from Zope.Publisher.Exceptions import Redirect, Retry
from Zope.Publisher.HTTP import HTTPRequest
@@ -59,8 +59,8 @@
" "
tries = 0
- def __call__(self, URL):
- return 'URL invoked: %s' % URL
+ def __call__(self, REQUEST):
+ return 'URL invoked: %s' % REQUEST.URL
def redirect_method(self, RESPONSE):
"Generates a redirect using the redirect() method."
@@ -70,7 +70,7 @@
"Generates a redirect using an exception."
raise Redirect("http://somewhere.com/exception")
- def conflict(self, URL, wait_tries):
+ def conflict(self, REQUEST, wait_tries):
"""
Returns 202 status only after (wait_tries) tries.
"""
@@ -93,12 +93,15 @@
obj._protected = tested_object()
pub = PublicationWithConflict(obj)
- request_payload = BrowserRequestPayload(pub)
- response_payload = BrowserResponsePayload()
+
+ def request_factory(input_stream, output_steam, env):
+ request = BrowserRequest(input_stream, output_steam, env)
+ request.setPublication(pub)
+ return request
td.setThreadCount(4)
# Bind to any port on localhost.
- self.server = PublisherHTTPServer(request_payload, response_payload,
+ self.server = PublisherHTTPServer(request_factory,
LOCALHOST, 0, task_dispatcher=td)
self.port = self.server.socket.getsockname()[1]
self.run_loop = 1