try module sub method response cmd split except ValueError Bad command

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
try:
(module, sub, method) = response['cmd'].split('.')
except ValueError: # Bad command format
raise RequestParseError(ERROR_WRONG_QUERY)
method = '%sView' % ''.join([x.capitalize() for x in method.split('_')])
try:
module = import_module('apps.{0}.{1}.api'.format(module, sub))
klass = getattr(module, method)
except (ImportError, AttributeError): # No module or no method
raise RequestParseError(ERROR_WRONG_QUERY)