changeset 596:e2c91ba44d6c

admin: Make sure we have a valid default site to start with.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 20 Jan 2016 21:36:51 -0800
parents eeb205ab8583
children 79a31a3c947b
files foodtruck/sites.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/foodtruck/sites.py	Wed Jan 20 21:35:58 2016 -0800
+++ b/foodtruck/sites.py	Wed Jan 20 21:36:51 2016 -0800
@@ -102,11 +102,13 @@
 
 
 class FoodTruckSites():
-    def __init__(self, config, current_site=None):
+    def __init__(self, config, current_site):
         self._sites = {}
         self._site_dirs = {}
         self.config = config
         self.current_site = current_site
+        if current_site is None:
+            raise Exception("No current site was given.")
 
     def get_root_dir(self, name=None):
         name = name or self.current_site
@@ -115,6 +117,8 @@
             return s
 
         scfg = self.config.get('sites/%s' % name)
+        if scfg is None:
+            raise Exception("No such site: %s" % name)
         root_dir = scfg.get('path')
         if root_dir is None:
             raise Exception("Site '%s' has no path defined." % name)