|
OpenQuizz
Une application de gestion des contenus pédagogiques
|


Public Member Functions | |
| def | __getattr__ (self, name) |
| def | __getitem__ (self, item) |
| def | find_one_or_404 (self, *args, **kwargs) |
Sub-class of PyMongo :class:`~pymongo.collection.Collection` with helpers.
| def __getattr__ | ( | self, | |
| name | |||
| ) |
| def __getitem__ | ( | self, | |
| item | |||
| ) |
| def find_one_or_404 | ( | self, | |
| * | args, | ||
| ** | kwargs | ||
| ) |
Find a single document or raise a 404.
This is like :meth:`~pymongo.collection.Collection.find_one`, but
rather than returning ``None``, cause a 404 Not Found HTTP status
on the request.
.. code-block:: python
@app.route("/user/<username>")
def user_profile(username):
user = mongo.db.users.find_one_or_404({"_id": username})
return render_template("user.html",
user=user)