Skip to content

Commit 779fd34

Browse files
committed
fixup
1 parent 0f5530a commit 779fd34

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

mig/api/server.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ def invalid_argument(arg):
158158
raise ValueError("Unexpected query variable: %s" % quoteattr(arg))
159159

160160

161-
# requests
162-
163161
class ValidationReport(RuntimeError):
164162
def __init__(self, errors_by_field):
165163
self.errors_by_field = errors_by_field
@@ -204,6 +202,7 @@ def _is_string_and_non_empty(value):
204202
password=_is_string_and_non_empty,
205203
))
206204

205+
207206
def validate_payload(definition, payload):
208207
args = definition(*[payload.get(field, None) for field in definition._fields])
209208

@@ -217,6 +216,7 @@ def validate_payload(definition, payload):
217216
else:
218217
return args
219218

219+
220220
def _create_and_expose_server(server, configuration):
221221
app = Flask('coreapi')
222222

@@ -232,26 +232,16 @@ def GET_user_username(username):
232232
def POST_user():
233233
payload = request.get_json()
234234

235-
# unpack the payload to a series of arguments
236235
try:
237236
validated = validate_payload(_REQUEST_ARGS_POST_USER, payload)
238237
except ValidationReport as vr:
239238
return http_error_from_status_code(400, None, vr.serialize())
240239

241240
args = list(validated)
242241

243-
try:
244-
245-
# user_dict = canonical_user(configuration, raw_user, raw_user.keys())
246-
# except (AttributeError, IndexError, KeyError) as e:
247-
# raise http_error_from_status_code(400, None)
248-
# except Exception as e:
249-
# pass
250-
251-
# try:
252-
createuser(configuration, args)
253-
except Exception as e:
254-
pass
242+
ret = createuser(configuration, args)
243+
if ret != 0:
244+
raise http_error_from_status_code(400, None)
255245

256246
greeting = 'hello client!'
257247
return Response(greeting, 201)

0 commit comments

Comments
 (0)