Merge "Remove use of '__import__'"
This commit is contained in:
commit
a274dcada0
@ -5,7 +5,8 @@ from wsme.utils import OrderedDict
|
||||
from wsme.protocol import CallContext, Protocol, media_type_accept
|
||||
|
||||
import wsme.rest
|
||||
import wsme.rest.args
|
||||
from wsme.rest import json
|
||||
from wsme.rest import xml
|
||||
import wsme.runtime
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -14,21 +15,22 @@ log = logging.getLogger(__name__)
|
||||
class RestProtocol(Protocol):
|
||||
name = 'rest'
|
||||
displayname = 'REST'
|
||||
dataformats = ['json', 'xml']
|
||||
content_types = ['application/json', 'text/xml']
|
||||
formatters = {
|
||||
'json': json,
|
||||
'xml': xml,
|
||||
}
|
||||
|
||||
def __init__(self, dataformats=None):
|
||||
if dataformats is None:
|
||||
dataformats = RestProtocol.dataformats
|
||||
dataformats = ('json', 'xml')
|
||||
|
||||
self.dataformats = OrderedDict()
|
||||
self.content_types = []
|
||||
|
||||
for dataformat in dataformats:
|
||||
__import__('wsme.rest.' + dataformat)
|
||||
dfmod = getattr(wsme.rest, dataformat)
|
||||
self.dataformats[dataformat] = dfmod
|
||||
self.content_types.extend(dfmod.accept_content_types)
|
||||
formatter = self.formatters[dataformat]
|
||||
self.dataformats[dataformat] = formatter
|
||||
self.content_types.extend(formatter.accept_content_types)
|
||||
|
||||
def accept(self, request):
|
||||
for dataformat in self.dataformats:
|
||||
|
Loading…
x
Reference in New Issue
Block a user