File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010from flask import Flask
1111from flask_mail import Mail
1212
13- from users .config import (
14- PROJECT_NAME ,
15- PUBLIC_URL ,
16- PROJECT_FAVICON_FILE ,
17- MAIL_CONFIG ,
18- SQLITE_DB_PATH ,
19- USER_ICONS )
20-
2113
2214def add_handler_once (logger , handler ):
2315 """A helper to add a handler to a logger, ensuring there are no duplicates.
@@ -75,16 +67,18 @@ def setup_logger():
7567
7668APP = Flask (__name__ )
7769
78- # Load configuration
79- APP . config [ 'PROJECT_NAME' ] = PROJECT_NAME
80- APP . config [ 'PUBLIC_URL' ] = PUBLIC_URL
81- APP . config [ 'PROJECT_FAVICON_FILE' ] = PROJECT_FAVICON_FILE
82- APP .config .update ( MAIL_CONFIG )
70+ # Load configuration from ``users.config``.
71+ # This will raise ``ImportError`` if such module isn't exist.
72+ # Simply copy the contents of ``config.py.example`` file,
73+ # and save it into a file named ``config.py``.
74+ APP .config .from_object ( "users.config" )
8375mail = Mail (APP )
84- APP .config ['DATABASE' ] = SQLITE_DB_PATH
85- APP .config ['USER_ICONS' ] = USER_ICONS
76+
77+ # backward-compat
78+ APP .config ['DATABASE' ] = APP .config ['SQLITE_DB_PATH' ]
79+
8680# Don't import actual view methods themselves - see:
8781# http://flask.pocoo.org/docs/patterns/packages/#larger-applications
8882# Also views must be imported AFTER app is created above.
8983# noinspection PyUnresolvedReferences
90- import users .views
84+ import users .views # noqa
Original file line number Diff line number Diff line change @@ -23,19 +23,24 @@ SQLITE_DB_PATH = os.path.abspath(
2323 )
2424)
2525
26- # MAIL SERVER
27- MAIL_CONFIG = dict(
28- MAIL_SERVER='smtp.gmail.com',
29- MAIL_PORT=587,
30- MAIL_USE_TLS=True,
31- MAIL_USE_SSL=False,
32- MAIL_USERNAME='',
33- MAIL_PASSWORD='',
34- MAIL_SUPPRESS_SEND=False,
35- )
26+ # Alternatively, set to ``127.0.0.1`` for development/testing.
27+ MAIL_SERVER = 'smtp.gmail.com'
28+
29+ # Alternatively, set to ``25`` for development/testing.
30+ MAIL_PORT = 587
31+
32+ MAIL_USE_TLS = True
33+ MAIL_USE_SSL = False
34+ MAIL_USERNAME = ''
35+ MAIL_PASSWORD = ''
36+
37+ # Set the value to ``True`` to suppress email sending.
38+ # Useful for testing/development where machine doesn't have
39+ # mail server installed in it.
40+ MAIL_SUPPRESS_SEND = False
3641
3742# MAIL ADMINISTRATOR
38- MAIL_ADMIN = ('InaSAFE User Map Administrator', MAIL_CONFIG[' MAIL_USERNAME'] )
43+ MAIL_ADMIN = ('Python Indonesia User Map Administrator', MAIL_USERNAME)
3944
4045# USER ICONS: All icon paths that are used.
4146USER_ICONS = dict(
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments