Book Image

Building Web Applications with Flask

By : Italo M Campelo Maia, Jack Stouffer, Gareth Dwyer, Italo Maia
Book Image

Building Web Applications with Flask

By: Italo M Campelo Maia, Jack Stouffer, Gareth Dwyer, Italo Maia

Overview of this book

Table of Contents (17 chapters)
Building Web Applications with Flask
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

How to configure extensions


Flask extensions are modules you import, (usually) initialize, and use to integrate with third-party libraries. They're (also) usually imported from flask.ext.<extension_name> (which is part of the extension pattern) and should be available in the PyPi repository under the BSD, MIT, or another less restrictive license.

It's good practice for an extension to have two states: uninitialized and initialized. This is good practice because your Flask application may not be available at the time you instantiate your extension. Our example in the previous chapter only initializes Flask-SQLAlchemy after it is imported in the main module. Ok, nice to know but how is the initialization process important?

Well, it's through the initialization that the extension fetches its configuration from the application. For example:

from flask import Flask
import logging

# set configuration for your Flask application or extensions
class Config(object):
    LOG_LEVEL = logging.WARNING...