Skip to content

Commit 7786138

Browse files
authored
Merge pull request #84 from perseids-project/configure-environment
Allow multiple config files
2 parents 0da6109 + 9cdad5c commit 7786138

File tree

14 files changed

+23
-24
lines changed

14 files changed

+23
-24
lines changed

README.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ Or with Docker and Docker Compose
7474
git clone https://github.com/perseids-project/digital_milliet
7575
cd digital_milliet
7676
docker-compose build
77-
docker-compose run web scripts/docker-setup.sh
7877
docker-compose up
79-
docker-compose run web scripts/docker-teardown.sh
8078
8179
For production deployment, see Puppet manifests in the puppet subdirectory of this repository.
8280

@@ -87,7 +85,7 @@ path can be supplied in an argument to the DigitalMilliet Flask Application:
8785

8886
.. code-block:: python
8987
90-
DigitalMilliet(app, config_file="path/to/your/config.cfg")
88+
DigitalMilliet(app, config_files=["path/to/your/config.cfg"])
9189
9290
9391
The default contents of this configuration file, with explanation of each setting, is provided below:

digital_milliet/digital_milliet.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@
2020
class DigitalMilliet(object):
2121
""" The Digital Milliet Web Application """
2222

23-
def __init__(self, app=None, config_file="config.cfg"):
23+
def __init__(self, app=None, config_files=["config.cfg"]):
2424
self.app = None
2525

2626
if app is not None:
2727
self.app = app
28-
self.init_app(config_file)
28+
self.init_app(config_files)
2929

30-
def init_app(self, config_file=None):
30+
def init_app(self, config_files=[]):
31+
32+
for config in config_files:
33+
self.app.config.from_pyfile(config, silent=False)
3134

32-
self.app.config.from_pyfile(config_file, silent=False)
3335
self.app.secret_key = self.app.config['SECRET_KEY']
3436
self.bower = Bower(self.app)
3537
self.markdown = Markdown(self.app)

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
build: .
55
ports:
66
- "5000:5000"
7-
command: scripts/wait-for-mongo.sh python3 run.py
7+
command: scripts/wait-for-mongo.sh python3 run.py config.cfg docker-config.cfg
88
volumes:
99
- .:/app
1010
depends_on:

puppet/templates/app.wsgi.epp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ from flask import Flask
99
from digital_milliet.digital_milliet import DigitalMilliet
1010

1111
application = Flask("digital_milliet")
12-
dm = DigitalMilliet(application,config_file="config.cfg")
12+
dm = DigitalMilliet(application,config_files=["config.cfg"])

run.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from flask import Flask
33
from digital_milliet.digital_milliet import DigitalMilliet
4+
import sys
5+
6+
config_files = ["config.cfg"]
7+
if len(sys.argv) > 1:
8+
config_files = sys.argv[1:]
9+
410
app = Flask('digital_milliet')
5-
dm = DigitalMilliet(app, config_file="config.cfg")
11+
dm = DigitalMilliet(app, config_files=config_files)
612
app.run(debug=True, host="0.0.0.0", port=5000)

runtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import argparse
66

77
app = Flask('digital_milliet')
8-
dm = DigitalMilliet(app, config_file="../tests/testconfig.cfg")
8+
dm = DigitalMilliet(app, config_files=["../tests/testconfig.cfg"])
99
mongo = dm.get_db()
1010

1111

scripts/docker-setup.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

scripts/docker-teardown.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/fixdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from digital_milliet.lib.commentaries import CommentaryHandler
66

77
app = Flask('digital_milliet')
8-
dm = DigitalMilliet(app, config_file="config.cfg")
8+
dm = DigitalMilliet(app, config_files=["config.cfg"])
99
person = {
1010
"@id": "http://data.perseus.org/sosol/users/Val%C3%A9rie%20Toillon",
1111
"type": 'Person',

scripts/fixdups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from digital_milliet.lib.author_builder import AuthorBuilder
66

77
app = Flask('digital_milliet')
8-
dm = DigitalMilliet(app, config_file="config.cfg")
8+
dm = DigitalMilliet(app, config_files=["config.cfg"])
99
person = {
1010
"@id": "http://data.perseus.org/sosol/users/Val%C3%A9rie%20Toillon",
1111
"type": 'Person',

0 commit comments

Comments
 (0)