OpenQuizz
Une application de gestion des contenus pédagogiques
BSONObjectIdConverter Class Reference
Inheritance diagram for BSONObjectIdConverter:
Collaboration diagram for BSONObjectIdConverter:

Public Member Functions

def to_python (self, value)
 
def to_url (self, value)
 
- Public Member Functions inherited from BaseConverter
def __init__ (self, map)
 

Additional Inherited Members

- Data Fields inherited from BaseConverter
 map
 
- Static Public Attributes inherited from BaseConverter
 regex
 
 weight
 

Detailed Description

A simple converter for the RESTful URL routing system of Flask.

.. code-block:: python

    @app.route("/<ObjectId:task_id>")
    def show_task(task_id):
        task = mongo.db.tasks.find_one_or_404(task_id)
        return render_template("task.html", task=task)

Valid object ID strings are converted into
:class:`~bson.objectid.ObjectId` objects; invalid strings result
in a 404 error. The converter is automatically registered by the
initialization of :class:`~flask_pymongo.PyMongo` with keyword
:attr:`ObjectId`.

Member Function Documentation

◆ to_python()

def to_python (   self,
  value 
)

Reimplemented from BaseConverter.

◆ to_url()

def to_url (   self,
  value 
)

Reimplemented from BaseConverter.


The documentation for this class was generated from the following file: