Skip to content
Snippets Groups Projects
Commit 68ffe865 authored by Vermaat's avatar Vermaat
Browse files

Monkey patch spyne to Json-serialize Fault objects

git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/branches/spyne@579 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
parent 7f986b76
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,8 @@ Mutalyzer webservice HTTP/RPC with JSON response payloads. ...@@ -3,6 +3,8 @@ Mutalyzer webservice HTTP/RPC with JSON response payloads.
""" """
from mutalyzer.util import monkey_patch_spyne; monkey_patch_spyne()
from spyne.application import Application from spyne.application import Application
from spyne.protocol.http import HttpRpc from spyne.protocol.http import HttpRpc
from spyne.protocol.json import JsonObject from spyne.protocol.json import JsonObject
......
...@@ -879,3 +879,25 @@ def monkey_patch_suds(): ...@@ -879,3 +879,25 @@ def monkey_patch_suds():
Import.open = _import_open_patched Import.open = _import_open_patched
Import.MUTALYZER_MONKEY_PATCHED = True Import.MUTALYZER_MONKEY_PATCHED = True
#monkey_patch_suds #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:
import monkey; monkey.monkey_patch_spyne()
from spyne.protocol.json import JsonObject
"""
from spyne.model.fault import Fault
def _to_dict(self, *args, **kwargs):
return dict(faultcode=self.faultcode, faultstring=self.faultstring)
Fault._to_dict = _to_dict
#monkey_patch_spyne
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