Skip to content
Snippets Groups Projects
Commit 76e90a4c authored by Vermaat's avatar Vermaat
Browse files

Merge spyne branch back in trunk

git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/trunk@586 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
parents 80db7b5b 2b47e863
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ To start the built-in HTTP server on port 8082:
import sys
from wsgiref.simple_server import make_server
from rpclib.server.wsgi import WsgiApplication
from spyne.server.wsgi import WsgiApplication
from mutalyzer.services import json
......
......@@ -44,13 +44,12 @@ apt-get install -y \
python-setuptools \
git-core
echo -e "${COLOR_INFO}Installing known-working rpclib from git master${COLOR_END}"
echo -e "${COLOR_INFO}Installing known-working spyne from git${COLOR_END}"
# For now we use a specific known-working version of rpclib. The project has
# in the meantime been renamed to Spyne and we should update some time.
# For now we use a specific known-working version of spyne.
pushd $(mktemp -d)
git clone https://github.com/martijnvermaat/rpclib.git .
git checkout mutalyzer
git clone https://github.com/arskom/spyne.git .
git checkout -b mutalyzer 065e475fa216837cd714e046e92d01a1799f78c2
python setup.py install
popd
......
......@@ -22,8 +22,8 @@ import os
RELEASE = False
__version_info__ = ('2', '0', 'beta-21', 'dev')
__date__ = '11 Jul 2012'
__version_info__ = ('2', '0', 'beta-22', 'dev')
__date__ = '23 Jul 2012'
__version__ = '.'.join(__version_info__)
......
"""
Collection of serilizable objects used by the SOAP webservice. They extend
from the rpclib ClassModel.
from the spyne ClassModel.
Default attributes for the rpclib ClassModel:
Default attributes for the spyne ClassModel:
- nillable = True
- min_occurs = 0
- max_occurs = 1
Additional attributes values for the rpclib String model:
Additional attributes values for the spyne String model:
- min_len = 0
- max_len = 'unbounded'
- pattern = None
......@@ -17,21 +17,21 @@ Additional attributes values for the rpclib String model:
"""
from rpclib.model.primitive import String, Integer, Boolean, DateTime
from rpclib.model.complex import ComplexModel, Array
from spyne.model.primitive import String, Integer, Boolean, DateTime
from spyne.model.complex import ComplexModel, Array
from mutalyzer import SOAP_NAMESPACE
class Mandatory(object):
"""
This is rpclib.model.primitive.Mandatory, but without min_length=1 for
This is spyne.model.primitive.Mandatory, but without min_length=1 for
the String model.
"""
String = String(min_occurs=1, nillable=False)
Integer = Integer(min_occurs=1, nillable=False)
Boolean = Boolean(min_occurs=1, nillable=False)
DateTime = DateTime(min_occurs=1, nillable=False)
String = String(type_name='mandatory_string', min_occurs=1, nillable=False)
Integer = Integer(type_name='mandatory_integer', min_occurs=1, nillable=False)
Boolean = Boolean(type_name='mandatory_boolean', min_occurs=1, nillable=False)
DateTime = DateTime(type_name='mandatory_date_time', min_occurs=1, nillable=False)
#Mandatory
......
......@@ -3,15 +3,21 @@ Mutalyzer webservice HTTP/RPC with JSON response payloads.
"""
from rpclib.application import Application
from rpclib.protocol.http import HttpRpc
from rpclib.protocol.json import JsonObject
from mutalyzer.util import monkey_patch_spyne; monkey_patch_spyne()
from spyne.application import Application
from spyne.protocol.http import HttpRpc
from spyne.protocol.json import JsonObject
import mutalyzer
from mutalyzer.services import rpc
# HTTP/RPC application.
# Note that we originally provided skip_depth=2 to the JsonObject constructor
# to get rid of some annoying wrappers around the json results. However, this
# breaks methods returning a primitive datatype (e.g. just a string). Might
# file a bug about this on spyne.
application = Application([rpc.MutalyzerService], tns=mutalyzer.SOAP_NAMESPACE,
in_protocol=HttpRpc(), out_protocol=JsonObject(skip_depth=2),
in_protocol=HttpRpc(), out_protocol=JsonObject(),
name='Mutalyzer')
......@@ -8,11 +8,11 @@ Mutalyzer RPC services.
"""
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 spyne.decorator import srpc
from spyne.service import ServiceBase
from spyne.model.primitive import String, Integer, Boolean, DateTime
from spyne.model.complex import Array
from spyne.model.fault import Fault
import os
import socket
from operator import itemgetter, attrgetter
......@@ -677,7 +677,7 @@ class MutalyzerService(ServiceBase):
result.molecule = O.getIndexedOutput('molecule', 0)
# We force the results to strings here, because some results
# may be of type Bio.Seq.Seq which rpclib doesn't like.
# may be of type Bio.Seq.Seq which spyne doesn't like.
#
# todo: We might have to also do this elsewhere.
......
......@@ -3,9 +3,9 @@ Mutalyzer SOAP/1.1 webservice.
"""
from rpclib.application import Application
from rpclib.protocol.soap import Soap11
from rpclib.server.wsgi import WsgiApplication
from spyne.application import Application
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
import mutalyzer
from mutalyzer.services import rpc
......@@ -20,6 +20,6 @@ application = Application([rpc.MutalyzerService], tns=mutalyzer.SOAP_NAMESPACE,
# 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
# get_interface_document method of spyne which we use to generate API
# documentation in website.py.
wsgi_application = WsgiApplication(application)
......@@ -861,7 +861,7 @@ def monkey_patch_suds():
Call this function before importing anything from the suds package. For
example, start your file with the following:
import monkey; monkey.monkey_patch_suds()
from mutalyzer.util import monkey_patch_suds; monkey_patch_suds()
from suds.client import Client
"""
from suds.xsd.sxbasic import Import
......@@ -879,3 +879,29 @@ def monkey_patch_suds():
Import.open = _import_open_patched
Import.MUTALYZER_MONKEY_PATCHED = True
#monkey_patch_suds
def monkey_patch_spyne():
"""
Apply our monkey-patch for the spyne package.
Fault objects cannot be serialized by the JsonObject output protocol,
this fixes it.
Call this function before importing anything from the spyne package. For
example, start your file with the following:
from mutalyzer.util import monkey_patch_spyne; monkey_patch_spyne()
from spyne.protocol.json import JsonObject
"""
from spyne.model.fault import Fault
if hasattr(Fault, '_to_dict'):
return
def _to_dict(self, *args, **kwargs):
return dict(Fault=dict(faultcode=self.faultcode,
faultstring=self.faultstring))
Fault._to_dict = _to_dict
#monkey_patch_spyne
......@@ -29,7 +29,7 @@ from lxml import etree
from cStringIO import StringIO
from simpletal import simpleTALES
from simpletal import simpleTAL
from rpclib.interface.wsdl import Wsdl11
from spyne.interface.wsdl import Wsdl11
import mutalyzer
from mutalyzer import util
......
......@@ -30,7 +30,7 @@ class TestServicesJson():
Running checkSyntax with a valid variant name should return True.
"""
r = call('checkSyntax', variant='AB026906.1:c.274G>T')
assert_equal(r['CheckSyntaxOutput']['valid'], True)
assert_equal(r['checkSyntaxResponse']['checkSyntaxResult']['valid'], True)
def test_checksyntax_invalid(self):
"""
......@@ -38,8 +38,8 @@ class TestServicesJson():
and give at least one error message.
"""
r = call('checkSyntax', variant='0:abcd')
assert_equal(r['CheckSyntaxOutput']['valid'], False)
assert len(r['CheckSyntaxOutput']['messages']['SoapMessage']) >= 1
assert_equal(r['checkSyntaxResponse']['checkSyntaxResult']['valid'], False)
assert len(r['checkSyntaxResponse']['checkSyntaxResult']['messages']['SoapMessage']) >= 1
def test_checksyntax_empty(self):
"""
......@@ -55,14 +55,14 @@ class TestServicesJson():
"""
r = call('transcriptInfo', LOVD_ver='123', build='hg19',
accNo='NM_002001.2')
assert_equal(r['Transcript']['trans_start'], -99)
assert_equal(r['Transcript']['trans_stop'], 1066)
assert_equal(r['Transcript']['CDS_stop'], 774)
assert_equal(r['transcriptInfoResponse']['transcriptInfoResult']['trans_start'], -99)
assert_equal(r['transcriptInfoResponse']['transcriptInfoResult']['trans_stop'], 1066)
assert_equal(r['transcriptInfoResponse']['transcriptInfoResult']['CDS_stop'], 774)
def test_info(self):
"""
Running the info method should give us some version information.
"""
r = call('info')
assert_equal(type(r['InfoOutput']['versionParts']['string']), list)
assert_equal(r['InfoOutput']['version'], mutalyzer.__version__)
assert_equal(type(r['infoResponse']['infoResult']['versionParts']['string']), list)
assert_equal(r['infoResponse']['infoResult']['version'], mutalyzer.__version__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment