Remove use of '__import__'
These are not discoverable and, in this particular instance, unnecessary. Change-Id: I43757263ebbb009d10a6023bbd126b41408cbdc0 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
64530e8eb5
commit
e90aecb68f
@ -5,7 +5,8 @@ from wsme.utils import OrderedDict
|
|||||||
from wsme.protocol import CallContext, Protocol, media_type_accept
|
from wsme.protocol import CallContext, Protocol, media_type_accept
|
||||||
|
|
||||||
import wsme.rest
|
import wsme.rest
|
||||||
import wsme.rest.args
|
from wsme.rest import json
|
||||||
|
from wsme.rest import xml
|
||||||
import wsme.runtime
|
import wsme.runtime
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -14,21 +15,22 @@ log = logging.getLogger(__name__)
|
|||||||
class RestProtocol(Protocol):
|
class RestProtocol(Protocol):
|
||||||
name = 'rest'
|
name = 'rest'
|
||||||
displayname = 'REST'
|
displayname = 'REST'
|
||||||
dataformats = ['json', 'xml']
|
formatters = {
|
||||||
content_types = ['application/json', 'text/xml']
|
'json': json,
|
||||||
|
'xml': xml,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, dataformats=None):
|
def __init__(self, dataformats=None):
|
||||||
if dataformats is None:
|
if dataformats is None:
|
||||||
dataformats = RestProtocol.dataformats
|
dataformats = ('json', 'xml')
|
||||||
|
|
||||||
self.dataformats = OrderedDict()
|
self.dataformats = OrderedDict()
|
||||||
self.content_types = []
|
self.content_types = []
|
||||||
|
|
||||||
for dataformat in dataformats:
|
for dataformat in dataformats:
|
||||||
__import__('wsme.rest.' + dataformat)
|
formatter = self.formatters[dataformat]
|
||||||
dfmod = getattr(wsme.rest, dataformat)
|
self.dataformats[dataformat] = formatter
|
||||||
self.dataformats[dataformat] = dfmod
|
self.content_types.extend(formatter.accept_content_types)
|
||||||
self.content_types.extend(dfmod.accept_content_types)
|
|
||||||
|
|
||||||
def accept(self, request):
|
def accept(self, request):
|
||||||
for dataformat in self.dataformats:
|
for dataformat in self.dataformats:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user