diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-06-24 10:05:22 +0200 |
|---|---|---|
| committer | Georgios Andreadis <info@gandreadis.com> | 2020-06-24 10:05:22 +0200 |
| commit | c7f773b027019086153f0260b507c8fa173ee5e8 (patch) | |
| tree | 982048b9a117f1c03abeb26ab84d70f4a82115f8 /opendc/util | |
| parent | bae760a62fc6a480fbe615dff6a7de03c7fd6d1d (diff) | |
Fix API serialization issues
Diffstat (limited to 'opendc/util')
| -rw-r--r-- | opendc/util/parameter_checker.py | 3 | ||||
| -rw-r--r-- | opendc/util/rest.py | 10 |
2 files changed, 4 insertions, 9 deletions
diff --git a/opendc/util/parameter_checker.py b/opendc/util/parameter_checker.py index 561ed497..d3e7ef13 100644 --- a/opendc/util/parameter_checker.py +++ b/opendc/util/parameter_checker.py @@ -66,8 +66,7 @@ def _format_parameter(parameter): def check(request, **kwargs): """Return True if all required parameters are there.""" - for location, params_required in kwargs.iteritems(): - + for location, params_required in kwargs.items(): params_actual = getattr(request, 'params_{}'.format(location)) missing_parameter = _missing_parameter(params_required, params_actual) diff --git a/opendc/util/rest.py b/opendc/util/rest.py index d5df5306..d892a358 100644 --- a/opendc/util/rest.py +++ b/opendc/util/rest.py @@ -40,16 +40,12 @@ class Request(object): # Parse the path and import the appropriate module try: - self.path = message['path'].encode('ascii', 'ignore').strip('/') + self.path = message['path'].strip('/') module_base = 'opendc.api.{}.endpoint' - module_path = self.path.translate(None, '{}').replace('/', '.') + module_path = self.path.replace('/', '.') self.module = importlib.import_module(module_base.format(module_path)) - - except UnicodeError: - raise exceptions.UnimplementedEndpointError('Non-ASCII path') - except ImportError: raise exceptions.UnimplementedEndpointError('Unimplemented endpoint: {}.'.format(self.path)) @@ -68,7 +64,7 @@ class Request(object): self.google_id = self._verify_token(self.token) except crypt.AppIdentityError as e: - raise exceptions.AuthorizationTokenError(e.message) + raise exceptions.AuthorizationTokenError(e) def _verify_token(self, token): """Return the ID of the signed-in user. |
