extensions.py
3.05 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# -*- coding: utf8 -*-
# This file is part of PyBossa.
#
# Copyright (C) 2015 SciFabric LTD.
#
# PyBossa is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyBossa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with PyBossa. If not, see <http://www.gnu.org/licenses/>.
"""
This module exports all the extensions used by PyBossa.
The objects are:
* sentinel: for caching data, ratelimiting, etc.
* signer: for signing emails, cookies, etc.
* mail: for sending emails,
* login_manager: to handle account sigin/signout
* facebook: for Facebook signin
* twitter: for Twitter signin
* google: for Google signin
* misaka: for app.long_description markdown support,
* babel: for i18n support,
* uploader: for file uploads support,
* csrf: for CSRF protection
* newsletter: for subscribing users to Mailchimp newsletter
"""
__all__ = ['sentinel', 'db', 'signer', 'mail', 'login_manager', 'facebook',
'twitter', 'google', 'misaka', 'babel', 'uploader', 'debug_toolbar',
'csrf', 'timeouts', 'ratelimits', 'user_repo', 'project_repo',
'task_repo', 'blog_repo', 'auditlog_repo', 'newsletter', 'importer',
'flickr', 'plugin_manager']
# CACHE
from pybossa.sentinel import Sentinel
sentinel = Sentinel()
# DB
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
db.slave_session = db.session
# Repositories
user_repo = None
project_repo = None
blog_repo = None
task_repo = None
auditlog_repo = None
# Signer
from pybossa.signer import Signer
signer = Signer()
# Mail
from flask.ext.mail import Mail
mail = Mail()
# Login Manager
from flask.ext.login import LoginManager
login_manager = LoginManager()
# Debug Toolbar
from flask.ext.debugtoolbar import DebugToolbarExtension
debug_toolbar = DebugToolbarExtension()
# OAuth providers
from pybossa.oauth_providers import Facebook
facebook = Facebook()
from pybossa.oauth_providers import Twitter
twitter = Twitter()
from pybossa.oauth_providers import Google
google = Google()
from pybossa.oauth_providers import Flickr
flickr = Flickr()
# Markdown support
from flask.ext.misaka import Misaka
misaka = Misaka()
# Babel
from flask.ext.babel import Babel
babel = Babel()
# Uploader
uploader = None
# Exporters
json_exporter = None
csv_exporter = None
# CSRF protection
from flask_wtf.csrf import CsrfProtect
csrf = CsrfProtect()
# Timeouts
timeouts = dict()
# Ratelimits
ratelimits = dict()
# Newsletter
from newsletter import Newsletter
newsletter = Newsletter()
# Importer
from importers import Importer
importer = Importer()
from flask.ext.plugins import PluginManager
plugin_manager = PluginManager()