summaryrefslogtreecommitdiff
path: root/src/mailman/rest/webservice.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-05-03 15:35:29 -0400
committerBarry Warsaw2009-05-03 15:35:29 -0400
commite920c98c72fc9674316ae32c26a81fe571964ea5 (patch)
tree905de48fe2f08c939b77e13f0fcf35ad1b6e8efa /src/mailman/rest/webservice.py
parent443aba66658347d0b747ff84ec1750cfb8c71924 (diff)
downloadmailman-e920c98c72fc9674316ae32c26a81fe571964ea5.tar.gz
mailman-e920c98c72fc9674316ae32c26a81fe571964ea5.tar.zst
mailman-e920c98c72fc9674316ae32c26a81fe571964ea5.zip
Diffstat (limited to 'src/mailman/rest/webservice.py')
-rw-r--r--src/mailman/rest/webservice.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/mailman/rest/webservice.py b/src/mailman/rest/webservice.py
index 8203b0439..fe14513b9 100644
--- a/src/mailman/rest/webservice.py
+++ b/src/mailman/rest/webservice.py
@@ -36,6 +36,7 @@ from zope.interface import implements
from zope.publisher.browser import BrowserRequest
from zope.publisher.publish import publish
+from mailman.config import config
from mailman.core.system import system
from mailman.interfaces.rest import IResolvePathNames
from mailman.rest.publication import AdminWebServicePublication
@@ -52,6 +53,11 @@ class AdminWebServiceApplication:
implements(IResolvePathNames)
def __init__(self, environ, start_response):
+ self.environ = environ
+ self.start_response = start_response
+
+ def __iter__(self):
+ environ = self.environ
# Create the request based on the HTTP method used.
method = environ.get('REQUEST_METHOD', 'GET').upper()
request = AdminWebServiceRequest(environ['wsgi.input'], environ)
@@ -63,9 +69,9 @@ class AdminWebServiceApplication:
request = publish(request, handle_errors=handle_errors)
# Start the WSGI server response.
response = request.response
- start_response(response.getStatusString(), response.getHeaders())
+ self.start_response(response.getStatusString(), response.getHeaders())
# Return the result body iterable.
- return response.consumeBodyIter()
+ return iter(response.consumeBodyIter())
def get(self, name):
"""Maps root names to resources."""
@@ -80,9 +86,7 @@ def start():
"""Start the WSGI admin REST service."""
zcml = resource_string('mailman.rest', 'configure.zcml')
xmlconfig.string(zcml)
- server = make_server('', 8001, AdminWebServiceApplication)
- return server
-
-
-if __name__ == '__main__':
- start().serve_forever()
+ host = config.webservice.hostname
+ port = int(config.webservice.port)
+ server = make_server(host, port, AdminWebServiceApplication)
+ server.serve_forever()