summaryrefslogtreecommitdiff
path: root/src/mailman/rest/webservice.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-05-04 11:05:51 -0400
committerBarry Warsaw2009-05-04 11:05:51 -0400
commit70e6738197f225d486a555bfe7fca81073f38347 (patch)
tree8e72b893df67d990ad888fc46964589321ab53a5 /src/mailman/rest/webservice.py
parente920c98c72fc9674316ae32c26a81fe571964ea5 (diff)
downloadmailman-70e6738197f225d486a555bfe7fca81073f38347.tar.gz
mailman-70e6738197f225d486a555bfe7fca81073f38347.tar.zst
mailman-70e6738197f225d486a555bfe7fca81073f38347.zip
A working test of the REST server. http://localhost:8001/3.0/sys returns
useful information. It's GET only atm.
Diffstat (limited to 'src/mailman/rest/webservice.py')
-rw-r--r--src/mailman/rest/webservice.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/mailman/rest/webservice.py b/src/mailman/rest/webservice.py
index fe14513b9..fc8bdfcf4 100644
--- a/src/mailman/rest/webservice.py
+++ b/src/mailman/rest/webservice.py
@@ -23,11 +23,16 @@ __metaclass__ = type
__all__ = [
'AdminWebServiceApplication',
'AdminWebServiceRequest',
- 'start',
+ 'make_server',
]
-from wsgiref.simple_server import make_server
+import logging
+
+# Don't use wsgiref.simple_server.make_server() because we need to override
+# BaseHTTPRequestHandler.log_message() so that logging output will go to the
+# proper Mailman logger instead of stderr, as is the default.
+from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
from lazr.restful.publisher import WebServiceRequestTraversal
from pkg_resources import resource_string
@@ -41,6 +46,8 @@ from mailman.core.system import system
from mailman.interfaces.rest import IResolvePathNames
from mailman.rest.publication import AdminWebServicePublication
+log = logging.getLogger('mailman.http')
+
class AdminWebServiceRequest(WebServiceRequestTraversal, BrowserRequest):
@@ -82,11 +89,20 @@ class AdminWebServiceApplication:
-def start():
- """Start the WSGI admin REST service."""
+class AdminWebServiceWSGIRequestHandler(WSGIRequestHandler):
+ """Handler class which just logs output to the right place."""
+
+ def log_message(self, format, *args):
+ """See `BaseHTTPRequestHandler`."""
+ log.info('%s - - %s', self.address_string(), format % args)
+
+
+def make_server():
+ """Create the WSGI admin REST server."""
zcml = resource_string('mailman.rest', 'configure.zcml')
xmlconfig.string(zcml)
host = config.webservice.hostname
port = int(config.webservice.port)
- server = make_server(host, port, AdminWebServiceApplication)
- server.serve_forever()
+ server = WSGIServer((host, port), AdminWebServiceWSGIRequestHandler)
+ server.set_app(AdminWebServiceApplication)
+ return server