Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB: raise 404 in get_one #15

Open
neithere opened this issue Dec 23, 2013 · 0 comments
Open

MongoDB: raise 404 in get_one #15

neithere opened this issue Dec 23, 2013 · 0 comments

Comments

@neithere
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant