annotate foodtruck/main.py @ 772:3885421c29a3

admin: Make the whole FoodTruck site into a blueprint. This makes it possible to use an app factory, which makes it easier to write unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 03 Jul 2016 07:54:54 -0700
parents 200c7063affa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 import logging
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 logger = logging.getLogger(__name__)
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6
619
200c7063affa admin: Change the default admin server port to 8090, add `--port` option.
Ludovic Chabant <ludovic@chabant.com>
parents: 602
diff changeset
7 def run_foodtruck(host=None, port=None, debug=False):
599
d7baac1d01e6 admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents: 588
diff changeset
8 if debug:
d7baac1d01e6 admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents: 588
diff changeset
9 import foodtruck.settings
d7baac1d01e6 admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents: 588
diff changeset
10 foodtruck.settings.DEBUG = debug
d7baac1d01e6 admin: Set the `DEBUG` flag before the app runs so we can read it during setup.
Ludovic Chabant <ludovic@chabant.com>
parents: 588
diff changeset
11
772
3885421c29a3 admin: Make the whole FoodTruck site into a blueprint.
Ludovic Chabant <ludovic@chabant.com>
parents: 619
diff changeset
12 from .web import create_foodtruck_app
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 try:
772
3885421c29a3 admin: Make the whole FoodTruck site into a blueprint.
Ludovic Chabant <ludovic@chabant.com>
parents: 619
diff changeset
14 app = create_foodtruck_app()
619
200c7063affa admin: Change the default admin server port to 8090, add `--port` option.
Ludovic Chabant <ludovic@chabant.com>
parents: 602
diff changeset
15 app.run(host=host, port=port, debug=debug, threaded=True)
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 except SystemExit:
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 # This is needed for Werkzeug's code reloader to be able to correctly
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 # shutdown the child process in order to restart it (otherwise, SSE
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 # generators will keep it alive).
602
c6bc0ef03f82 admin: Better UI for publishing websites.
Ludovic Chabant <ludovic@chabant.com>
parents: 599
diff changeset
20 from . import pubutil
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 logger.debug("Shutting down SSE generators from main...")
602
c6bc0ef03f82 admin: Better UI for publishing websites.
Ludovic Chabant <ludovic@chabant.com>
parents: 599
diff changeset
22 pubutil.server_shutdown = True
587
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 raise
d4a01a023998 admin: Add "FoodTruck" admin panel from the side experiment project.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24