Browse Source

Read config from default settings and/or env file

Matthias Vogelgesang 7 years ago
parent
commit
f8641f8f1b
3 changed files with 8 additions and 4 deletions
  1. 1 0
      .gitignore
  2. 3 4
      nova/__init__.py
  3. 4 0
      nova/settings.py

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 *.pyc
+*.cfg
 build/
 dist/
 nova.egg-info/

+ 3 - 4
nova/__init__.py

@@ -16,12 +16,11 @@ __version__ = '0.1.0'
 app = Flask(__name__)
 app.secret_key = 'KU5bF1K4ZQdjHSg91bJGnAkStAeEDIAg'
 
-app.config['DEBUG'] = True
-app.config['NOVA_ROOT_PATH'] = '/home/vogelgesang/tmp/nova'
+app.config.from_object('nova.settings')
+app.config.from_envvar('NOVA_SETTINGS', silent=True)
+
 app.config['NOVA_FS_LAYOUT'] = jinja2.Template('{{ root }}/{{ user }}/{{ dataset }}')
 app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(app.config['NOVA_ROOT_PATH'], 'nova.db')
-app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
-app.config['CELERY_BROKER_URL'] = 'amqp://guest@localhost//'
 
 
 @app.template_filter('naturaltime')

+ 4 - 0
nova/settings.py

@@ -0,0 +1,4 @@
+DEBUG = False
+NOVA_ROOT_PATH = '.'
+SQLALCHEMY_TRACK_MODIFICATIONS = True
+CELERY_BROKER_URL = 'amqp://guest@localhost//'