Skip to content
Myr

subclassing.rst

This file

Path

docs/patterns/subclassing.rst

17 lines · 676 bytes

Last changed by

Not known.

History of this file

Take it

1Subclassing Flask2=================34The :class:`~flask.Flask` class is designed for subclassing.56For example, you may want to override how request parameters are handled to preserve their order::78    from flask import Flask, Request9    from werkzeug.datastructures import ImmutableOrderedMultiDict10    class MyRequest(Request):11        """Request subclass to override request parameter storage"""12        parameter_storage_class = ImmutableOrderedMultiDict13    class MyFlask(Flask):14        """Flask subclass using the custom request class"""15        request_class = MyRequest1617This is the recommended approach for overriding or augmenting Flask's internal functionality.