Mercurial > piecrust2
comparison foodtruck/sites.py @ 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 | d4a01a023998 |
children | 3cec8634209a |
comparison
equal
deleted
inserted
replaced
595:eeb205ab8583 | 596:e2c91ba44d6c |
---|---|
100 logger.debug("Bake ended for %s." % self.sitename) | 100 logger.debug("Bake ended for %s." % self.sitename) |
101 self.callback() | 101 self.callback() |
102 | 102 |
103 | 103 |
104 class FoodTruckSites(): | 104 class FoodTruckSites(): |
105 def __init__(self, config, current_site=None): | 105 def __init__(self, config, current_site): |
106 self._sites = {} | 106 self._sites = {} |
107 self._site_dirs = {} | 107 self._site_dirs = {} |
108 self.config = config | 108 self.config = config |
109 self.current_site = current_site | 109 self.current_site = current_site |
110 if current_site is None: | |
111 raise Exception("No current site was given.") | |
110 | 112 |
111 def get_root_dir(self, name=None): | 113 def get_root_dir(self, name=None): |
112 name = name or self.current_site | 114 name = name or self.current_site |
113 s = self._site_dirs.get(name) | 115 s = self._site_dirs.get(name) |
114 if s: | 116 if s: |
115 return s | 117 return s |
116 | 118 |
117 scfg = self.config.get('sites/%s' % name) | 119 scfg = self.config.get('sites/%s' % name) |
120 if scfg is None: | |
121 raise Exception("No such site: %s" % name) | |
118 root_dir = scfg.get('path') | 122 root_dir = scfg.get('path') |
119 if root_dir is None: | 123 if root_dir is None: |
120 raise Exception("Site '%s' has no path defined." % name) | 124 raise Exception("Site '%s' has no path defined." % name) |
121 if not os.path.isdir(root_dir): | 125 if not os.path.isdir(root_dir): |
122 raise Exception("Site '%s' has an invalid path." % name) | 126 raise Exception("Site '%s' has an invalid path." % name) |