1.1 --- a/WebStack/Adapters/BaseHTTPRequestHandler.py Thu Mar 24 17:39:36 2005 +0000
1.2 +++ b/WebStack/Adapters/BaseHTTPRequestHandler.py Thu Mar 24 17:40:12 2005 +0000
1.3 @@ -77,4 +77,18 @@
1.4
1.5 trans.commit()
1.6
1.7 +default_address = ("", 8080)
1.8 +
1.9 +def deploy(resource, authenticator=None, address=None):
1.10 +
1.11 + """
1.12 + Deploy the given 'resource', with the given optional 'authenticator', at the
1.13 + given optional 'address', where 'address' is a 2-tuple of the form
1.14 + (host_string, port_integer).
1.15 + """
1.16 +
1.17 + handler = HandlerFactory(resource, authenticator)
1.18 + server = BaseHTTPServer.HTTPServer(address or default_address, handler)
1.19 + server.serve_forever()
1.20 +
1.21 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/WebStack/Adapters/CGI.py Thu Mar 24 17:39:36 2005 +0000
2.2 +++ b/WebStack/Adapters/CGI.py Thu Mar 24 17:40:12 2005 +0000
2.3 @@ -8,7 +8,7 @@
2.4 from WebStack.Generic import EndOfResponse
2.5 import sys, os
2.6
2.7 -def respond(resource, authenticator=None, input=None, output=None, env=None, handle_errors=1):
2.8 +def deploy(resource, authenticator=None, input=None, output=None, env=None, handle_errors=1):
2.9
2.10 """
2.11 Dispatch to the root application-specific 'resource'. Employ the optional
3.1 --- a/WebStack/Adapters/Twisted.py Thu Mar 24 17:39:36 2005 +0000
3.2 +++ b/WebStack/Adapters/Twisted.py Thu Mar 24 17:40:12 2005 +0000
3.3 @@ -7,6 +7,8 @@
3.4 import WebStack.Twisted
3.5 from WebStack.Generic import EndOfResponse
3.6 import twisted.web.resource
3.7 +import twisted.web.server
3.8 +import twisted.internet.reactor
3.9
3.10 class Dispatcher(twisted.web.resource.Resource):
3.11
3.12 @@ -54,4 +56,23 @@
3.13 request.finish()
3.14 return twisted.web.server.NOT_DONE_YET
3.15
3.16 +default_address = ("", 8080)
3.17 +
3.18 +def deploy(resource, authenticator=None, address=None):
3.19 +
3.20 + """
3.21 + Deploy the given 'resource', with the given optional 'authenticator', at the
3.22 + given optional 'address', where 'address' is a 2-tuple of the form
3.23 + (host_string, port_integer).
3.24 +
3.25 + NOTE: Twisted only makes use of the port number provided in the 'address'.
3.26 + """
3.27 +
3.28 + address = address or default_address
3.29 +
3.30 + top_level = Dispatcher(resource, authenticator)
3.31 + site = twisted.web.server.Site(top_level)
3.32 + twisted.internet.reactor.listenTCP(address[1], site)
3.33 + twisted.internet.reactor.run()
3.34 +
3.35 # vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/WebStack/Adapters/WSGI.py Thu Mar 24 17:39:36 2005 +0000
4.2 +++ b/WebStack/Adapters/WSGI.py Thu Mar 24 17:40:12 2005 +0000
4.3 @@ -6,6 +6,7 @@
4.4
4.5 import WebStack.WSGI
4.6 from WebStack.Generic import EndOfResponse
4.7 +from Helpers.wsgi_cgi import run_with_cgi
4.8
4.9 class WSGIAdapter:
4.10
4.11 @@ -66,4 +67,17 @@
4.12 )
4.13 return [trans.get_wsgi_content()]
4.14
4.15 +def deploy(resource, authenticator=None, address=None):
4.16 +
4.17 + """
4.18 + Deploy the given 'resource', with the given optional 'authenticator', at the
4.19 + given optional 'address', where 'address' is a 2-tuple of the form
4.20 + (host_string, port_integer).
4.21 +
4.22 + NOTE: The 'address' is ignored with the current WSGI implementation.
4.23 + """
4.24 +
4.25 + handler = WSGIAdapter(resource, authenticator)
4.26 + run_with_cgi(handler)
4.27 +
4.28 # vim: tabstop=4 expandtab shiftwidth=4