forked from frol/flask-restplus-server-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
60 lines (45 loc) · 1.42 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# encoding: utf-8
# pylint: disable=invalid-name,wrong-import-position
"""
Extensions setup
================
Extensions provide access to common resources of the application.
Please, put new extension instantiations and initializations here.
"""
from flask_cors import CORS
cross_origin_resource_sharing = CORS()
from sqlalchemy_utils import force_auto_coercion, force_instant_defaults
force_auto_coercion()
force_instant_defaults()
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
from flask_login import LoginManager
login_manager = LoginManager()
from flask_marshmallow import Marshmallow
marshmallow = Marshmallow()
from . import api
from .auth import OAuth2Provider
oauth2 = OAuth2Provider()
class AlembicDatabaseMigrationConfig(object):
"""
Helper config holder that provides missing functions of Flask-Alembic
package since we use custom invoke tasks instead.
"""
def __init__(self, database, directory='migrations', **kwargs):
self.db = database
self.directory = directory
self.configure_args = kwargs
def init_app(app):
"""
Application extensions initialization.
"""
for extension in (
cross_origin_resource_sharing,
db,
login_manager,
marshmallow,
api,
oauth2,
):
extension.init_app(app)
app.extensions['migrate'] = AlembicDatabaseMigrationConfig(db, compare_type=True)