Given
slot = Slot.get_one(db, {'_id': ObjectId(slot_id)})
if not slot:
abort(404)
return render_template('foo.html', slot=slot)
Desired
slot = Slot.get_one(db, {'_id': ObjectId(slot_id)}) # if not found, `abort(404)` is called
return render_template('foo.html', slot=slot)
This implies one of these options:
- a backwards-incompatible change of behaviour + dependency on a certain web framework
- a mechanism to customize the behaviour (on app level?) by (re)defining the exception factory (e.g.
NotFound / lambda: abort(404) / None).
The second option is of course much better.
Given
Desired
This implies one of these options:
NotFound/lambda: abort(404)/None).The second option is of course much better.