1.1 --- a/WebStack/Adapters/JavaServlet.py Sun Jan 15 23:18:29 2006 +0000
1.2 +++ b/WebStack/Adapters/JavaServlet.py Sun Jan 15 23:20:27 2006 +0000
1.3 @@ -22,6 +22,35 @@
1.4
1.5 import WebStack.JavaServlet
1.6 from WebStack.Generic import EndOfResponse
1.7 +from javax.servlet.http import HttpServlet
1.8 +
1.9 +def deploy(resource, authenticator=None, address=None, handle_errors=1):
1.10 +
1.11 + """
1.12 + Deploy the given 'resource' and optional 'authenticator'.
1.13 + The optional 'handle_errors' flag, if set to false, causes tracebacks to be
1.14 + displayed in the browser.
1.15 +
1.16 + The optional 'address' parameter is deliberately ignored.
1.17 + """
1.18 +
1.19 + # NOTE: Since jython 2.1 does not support the nested scope mechanisms
1.20 + # NOTE: required to just drop the above parameters into methods even as
1.21 + # NOTE: default parameters, we employ class attributes.
1.22 +
1.23 + class _Deploy(HttpServlet):
1.24 + def __init__(self):
1.25 + HttpServlet.__init__(self)
1.26 + self.dispatcher = Dispatcher(self.resource, self.authenticator, self.handle_errors)
1.27 +
1.28 + def service(self, request, response):
1.29 + self.dispatcher.service(request, response)
1.30 +
1.31 + _Deploy.resource = resource
1.32 + _Deploy.authenticator = authenticator
1.33 + _Deploy.handle_errors = handle_errors
1.34 +
1.35 + return _Deploy
1.36
1.37 class Dispatcher:
1.38