Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Building Web Applications with Flask

You're reading from   Building Web Applications with Flask Use Python and Flask to build amazing web applications, just the way you want them!

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781784396152
Length 160 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Italo Maia Italo Maia
Author Profile Icon Italo Maia
Italo Maia
Arrow right icon
View More author details
Toc

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images