Skip to content

MongoDB: raise 404 in get_one #15

@neithere

Description

@neithere

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:

  1. a backwards-incompatible change of behaviour + dependency on a certain web framework
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions