diff --git a/bin/mutalyzer-webservice.wsgi b/bin/mutalyzer-webservice.wsgi index 5a01545e2e705cf9b04bc26b14da521c24e8c3d9..ff63ee0b500d803e9e5e4f8ad8d0a82e35d30fde 100755 --- a/bin/mutalyzer-webservice.wsgi +++ b/bin/mutalyzer-webservice.wsgi @@ -30,7 +30,7 @@ To start the built-in HTTP server on port 8081: import sys from wsgiref.simple_server import make_server -from mutalyzer import webservice +from mutalyzer.services import soap DEFAULT_PORT = 8081 @@ -38,7 +38,7 @@ DEFAULT_PORT = 8081 # Unfortunately we cannot instantiate wsgi.Application here, see the note # near the bottom of mutalyzer/webservice.py. -application = webservice.application +application = soap.wsgi_application if __name__ == '__main__': diff --git a/mutalyzer/services/__init__.py b/mutalyzer/services/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..05b3d031865b91b2a3ebd2ead081592a52a119e2 --- /dev/null +++ b/mutalyzer/services/__init__.py @@ -0,0 +1,3 @@ +""" +Services (RPC) for Mutalyzer. +""" diff --git a/mutalyzer/webservice.py b/mutalyzer/services/rpc.py similarity index 97% rename from mutalyzer/webservice.py rename to mutalyzer/services/rpc.py index 826a0ce18463ed0383421f81e4ae712e969f7ffc..220cf46bdc71cba498bdb5af9601a7dcf0395e9e 100644 --- a/mutalyzer/webservice.py +++ b/mutalyzer/services/rpc.py @@ -1,8 +1,6 @@ """ -Mutalyzer webservices. +Mutalyzer RPC services. -@todo: Do we really use namespaces correctly? -@todo: For some reason, the server exposes its location including ?wsdl. @todo: More thourough input checking. The @soap decorator does not do any kind of strictness checks on the input. For example, in transcriptInfo, the build argument must really be present. (Hint: @@ -10,24 +8,11 @@ Mutalyzer webservices. """ -# WSGI applications should never print anything to stdout. We redirect to -# stderr, but eventually Mutalyzer should be fixed to never just 'print' -# anything. -# http://code.google.com/p/modwsgi/wiki/DebuggingTechniques -import sys -sys.stdout = sys.stderr - -# Log exceptions to stdout -import logging; logging.basicConfig() - -from rpclib.application import Application -from rpclib.protocol.soap import Soap11 from rpclib.decorator import srpc from rpclib.service import ServiceBase from rpclib.model.primitive import String, Integer, Boolean, DateTime from rpclib.model.complex import Array from rpclib.model.fault import Fault -from rpclib.server.wsgi import WsgiApplication import os import socket from operator import itemgetter, attrgetter @@ -1100,14 +1085,3 @@ class MutalyzerService(ServiceBase): return descriptions #getdbSNPDescriptions #MutalyzerService - - -# WSGI application for use with e.g. Apache/mod_wsgi -soap_application = Application([MutalyzerService], mutalyzer.SOAP_NAMESPACE, - in_protocol=Soap11(), out_protocol=Soap11(), - name='Mutalyzer') -# Note: We would like to create the wsgi.Application instance only in the -# bin/mutalyzer-webservice.wsgi script, but unfortunately this breaks the -# get_wsdl method of soap_application which we use to generate API -# documentation in website.py. -application = WsgiApplication(soap_application) diff --git a/mutalyzer/services/soap.py b/mutalyzer/services/soap.py new file mode 100644 index 0000000000000000000000000000000000000000..31bb4e67d99376e8504c26af1a694dce1f19976d --- /dev/null +++ b/mutalyzer/services/soap.py @@ -0,0 +1,25 @@ +""" +Mutalyzer SOAP/1.1 webservice. +""" + + +from rpclib.application import Application +from rpclib.protocol.soap import Soap11 +from rpclib.server.wsgi import WsgiApplication + +import mutalyzer +from mutalyzer.services import rpc + + +# SOAP/1.1 application. +application = Application([rpc.MutalyzerService], tns=mutalyzer.SOAP_NAMESPACE, + in_protocol=Soap11(), out_protocol=Soap11(), + name='Mutalyzer') + + +# Below we define WSGI applications for use with e.g. Apache/mod_wsgi. +# Note: We would like to create the wsgi.Application instance only in the +# bin/mutalyzer-webservice.wsgi script, but unfortunately this breaks the +# get_interface_document method of rpclib which we use to generate API +# documentation in website.py. +wsgi_application = WsgiApplication(application) diff --git a/mutalyzer/website.py b/mutalyzer/website.py index 67245a8f4a3b7527713bf3489e77107978442513..da8c89b1840e4d09f49c571cff76f7a1bfeb1e7c 100644 --- a/mutalyzer/website.py +++ b/mutalyzer/website.py @@ -34,7 +34,7 @@ import mutalyzer from mutalyzer import util from mutalyzer import config from mutalyzer.grammar import Grammar -from mutalyzer import webservice +from mutalyzer.services import soap from mutalyzer import variantchecker from mutalyzer.output import Output from mutalyzer.mapping import Converter @@ -1444,7 +1444,7 @@ class Documentation: @todo: Cache this transformation. """ url = web.ctx.homedomain + web.ctx.homepath + WEBSERVICE_LOCATION - wsdl = Wsdl11(webservice.soap_application.interface) + wsdl = Wsdl11(soap.application.interface) wsdl.build_interface_document(url) wsdl_handle = StringIO(wsdl.get_interface_document()) xsl_handle = open(os.path.join(mutalyzer.package_root(), WSDL_VIEWER),