extensions.rst
This file
Path
docs/extensions.rst
48 lines · 1.8 KiB
Last changed by
Reworded before 0.8 ext docs.Armin Ronacherbefore adoption4573715
History of this fileTake it
Started extensions introduction documentArmin Ronacherbefore adoption933d203
lines 1–25why, one step back1Flask Extensions2================34Flask extensions extend the functionality of Flask in various different5ways. For instance they add support for databases and other common tasks.67Finding Extensions8------------------910Flask extensions are listed on the `Flask Extension Registry`_ and can be11downloaded with ``easy_install`` or ``pip``. If you add a Flask extension12as dependency to your ``requirements.rst`` or ``setup.py`` file they are13usually installed with a simple command or when your application installs.1415Using Extensions16----------------1718Extensions typically have documentation that goes along that shows how to19use it. There are no general rules in how extensions are supposed to20behave but they are imported from common locations. If you have an21extension called ``Flask-Foo`` or ``Foo-Flask`` it will be always22importable from ``flask.ext.foo``::2324 from flask.ext import foo25Reworded before 0.8 ext docs.Armin Ronacherbefore adoption4573715
lines 26–27why, one step back26Flask Before 0.827----------------Started extensions introduction documentArmin Ronacherbefore adoption933d203
lines 28–30why, one step back2829If you are using Flask 0.7 or earlier the :data:`flask.ext` package will not30exist, instead you have to import from ``flaskext.foo`` or ``flask_foo``Reworded before 0.8 ext docs.Armin Ronacherbefore adoption4573715
lines 31–35why, one step back31depending on how the extension is distributed. If you want to develop an32application that supports Flask 0.7 or earlier you should still import33from the :data:`flask.ext` package. We provide you with a compatibility34module that provides this package for older versions of Flask. You can35download it from github: `flaskext_compat.py`_Started extensions introduction documentArmin Ronacherbefore adoption933d203
line 36why, one step back36Explicitly activate compat moduleArmin Ronacherbefore adoption7997bae
line 37why, one step back37And here is how you can use it::Started extensions introduction documentArmin Ronacherbefore adoption933d203
lines 38–39why, one step back3839 import flaskext_compatExplicitly activate compat moduleArmin Ronacherbefore adoption7997bae
lines 40–41why, one step back40 flaskext_compat.activate()41Started extensions introduction documentArmin Ronacherbefore adoption933d203
lines 42–43why, one step back42 from flask.ext import foo43import -> activateArmin Ronacherbefore adoption2b8ea40
line 44why, one step back44Once the ``flaskext_compat`` module is activated the :data:`flask.ext` willStarted extensions introduction documentArmin Ronacherbefore adoption933d203
lines 45–48why, one step back45exist and you can start importing from there.4647.. _Flask Extension Registry: http://flask.pocoo.org/extensions/48.. _flaskext_compat.py: https://github.com/mitsuhiko/flask/raw/master/scripts/flaskext_compat.py