Move the protocols to a dedicated module, and their activation more explicit
--HG-- rename : wsme/restjson.py => wsme/protocols/restjson.py rename : wsme/restxml.py => wsme/protocols/restxml.py rename : wsme/soap.py => wsme/protocols/soap.py rename : wsme/templates/__init__.py => wsme/protocols/templates/__init__.py rename : wsme/templates/fault.html => wsme/protocols/templates/fault.html rename : wsme/templates/soap.html => wsme/protocols/templates/soap.html rename : wsme/templates/wsdl.html => wsme/protocols/templates/wsdl.html
This commit is contained in:
parent
ffd8758b90
commit
843c6a3d0f
@ -14,9 +14,7 @@ Then::
|
||||
from webob.dec import wsgify
|
||||
from wsme import *
|
||||
|
||||
import wsme.restjson
|
||||
import wsme.restxml
|
||||
import wsme.soap
|
||||
from wsme.protocols import restxml, restjson, soap
|
||||
|
||||
import logging
|
||||
|
||||
|
@ -128,19 +128,22 @@ class validate(object):
|
||||
|
||||
|
||||
class WSRoot(object):
|
||||
def __init__(self, protocols=None):
|
||||
def __init__(self, protocols=[]):
|
||||
self._debug = True
|
||||
if protocols is None:
|
||||
protocols = registered_protocols.keys()
|
||||
self.protocols = {}
|
||||
for protocol in protocols:
|
||||
self.addprotocol(protocol)
|
||||
|
||||
self._api = None
|
||||
|
||||
def addprotocol(self, protocol):
|
||||
if isinstance(protocol, str):
|
||||
protocol = registered_protocols[protocol]()
|
||||
self.protocols[protocol.name] = protocol
|
||||
protocol.root = weakref.proxy(self)
|
||||
|
||||
self._api = None
|
||||
|
||||
def getapi(self):
|
||||
if self._api is None:
|
||||
self._api = [i for i in scan_api(self)]
|
||||
|
0
wsme/protocols/templates/__init__.py
Normal file
0
wsme/protocols/templates/__init__.py
Normal file
@ -75,6 +75,9 @@ class TestController(unittest.TestCase):
|
||||
assert wsme.controller.registered_protocols['dummy'] == DummyProtocol
|
||||
|
||||
r = WSRoot()
|
||||
assert len(r.protocols) == 0
|
||||
|
||||
r.addprotocol('dummy')
|
||||
assert r.protocols['dummy']
|
||||
|
||||
r = WSRoot(['dummy'])
|
||||
|
@ -2,12 +2,13 @@ import decimal
|
||||
import base64
|
||||
|
||||
import wsme.tests.protocol
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except:
|
||||
import json
|
||||
|
||||
import wsme.restjson
|
||||
import wsme.protocols.restjson
|
||||
from wsme.utils import *
|
||||
|
||||
def prepare_value(value, datatype):
|
||||
|
@ -10,7 +10,7 @@ try:
|
||||
except:
|
||||
import cElementTree as et
|
||||
|
||||
import wsme.restxml
|
||||
import wsme.protocols.restxml
|
||||
|
||||
|
||||
def dumpxml(key, obj, datatype=None):
|
||||
|
@ -9,7 +9,7 @@ try:
|
||||
except:
|
||||
import cElementTree as et
|
||||
|
||||
import wsme.soap
|
||||
from wsme.protocols.soap import SoapProtocol
|
||||
import wsme.utils
|
||||
|
||||
tns = "http://foo.bar.baz/soap/"
|
||||
@ -114,7 +114,7 @@ def fromsoap(el):
|
||||
|
||||
|
||||
class TestSOAP(wsme.tests.protocol.ProtocolTestCase):
|
||||
protocol = wsme.soap.SoapProtocol(
|
||||
protocol = SoapProtocol(
|
||||
tns=tns, typenamespace=typenamespace)
|
||||
|
||||
def test_simple_call(self):
|
||||
|
Loading…
Reference in New Issue
Block a user