Actions
Fix #9017
closed[paddles] implement validation across all controller methods
% Done:
0%
Source:
Development
Tags:
Backport:
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):
Description
paddles has a lot of boilerplate in controllers that look like:
@index.when(method='POST', template='json') def index_post(self): # save to DB here try: name = request.json.get('name') except ValueError: rollback() error('/errors/invalid/', 'could not decode JSON body') if not name: error('/errors/invalid/', "could not find required key: 'name'") if not Run.query.filter_by(name=name).first(): log.info("Creating run: %s", name) Run(name) return dict() else: error('/errors/invalid/', "run with name %s already exists" % name)
That pattern is repeated in a lot of places. This is how the above should look like with `pecan-notario`:
@index.when(method='POST', template='json') @validate(('name', types.string), handler='/errors/schema') def index_post(self): name = request.json.get('name') if not Run.query.filter_by(name=name).first(): log.info("Creating run: %s", name) Run(name) return dict() else: error('/errors/invalid/', "run with name %s already exists" % name)
Updated by Alfredo Deza over 9 years ago
- Status changed from New to Fix Under Review
Pull request opened https://github.com/ceph/paddles/pull/46
Updated by Sage Weil about 6 years ago
- Status changed from Fix Under Review to Rejected
Actions