changeset 669:65706804e1de

admin: Fix crash when running FoodTruck as a standalone web app.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 03 Mar 2016 21:36:04 -0800
parents a1b69b320217
children a409a7bb3948
files foodtruck/pubutil.py foodtruck/web.py
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/foodtruck/pubutil.py	Thu Mar 03 20:24:42 2016 -0800
+++ b/foodtruck/pubutil.py	Thu Mar 03 21:36:04 2016 -0800
@@ -22,7 +22,7 @@
     raise KeyboardInterrupt()
 
 
-if app.config['FOODTRUCK_CMDLINE_MODE']:
+if app.config.get('FOODTRUCK_CMDLINE_MODE', False):
     # Make sure CTRL+C works correctly.
     signal.signal(signal.SIGINT,
                   lambda *args: _shutdown_server_and_raise_sigint())
--- a/foodtruck/web.py	Thu Mar 03 20:24:42 2016 -0800
+++ b/foodtruck/web.py	Thu Mar 03 21:36:04 2016 -0800
@@ -14,14 +14,14 @@
 app.config.from_object('foodtruck.settings')
 app.config.from_envvar('FOODTRUCK_SETTINGS', silent=True)
 
-admin_root = app.config['FOODTRUCK_ROOT'] or os.getcwd()
+admin_root = app.config.get('FOODTRUCK_ROOT', os.getcwd())
 config_path = os.path.join(admin_root, 'app.cfg')
 
 # If we're being run as the `chef admin run` command, from inside a PieCrust
 # website, do a few things differently.
 _procedural_config = None
 
-if (app.config['FOODTRUCK_CMDLINE_MODE'] and
+if (app.config.get('FOODTRUCK_CMDLINE_MODE', False) and
         os.path.isfile(os.path.join(admin_root, 'config.yml'))):
     app.secret_key = os.urandom(22)
     app.config['LOGIN_DISABLED'] = True
@@ -156,7 +156,7 @@
 
 from foodtruck.bcryptfallback import Bcrypt
 if (getattr(Bcrypt, 'is_fallback_bcrypt', None) is True and
-        not app.config['FOODTRUCK_CMDLINE_MODE']):
+        not app.config.get('FOODTRUCK_CMDLINE_MODE', False)):
     raise Exception(
             "You're running FoodTruck outside of `chef`, and will need to "
             "install Flask-Bcrypt to get more proper security.")