diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-07-13 12:33:52 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-07-14 12:55:14 -0500 |
commit | 975be468cfc47e14cafb1b1bc8a6eb0e9f3704a0 (patch) | |
tree | c8343c81eefaa4b596f1fea12535d0c33e6fb801 | |
parent | 71eb4577485cc3130952f1f831960b87980ed400 (diff) | |
download | mediagoblin-975be468cfc47e14cafb1b1bc8a6eb0e9f3704a0.tar.lz mediagoblin-975be468cfc47e14cafb1b1bc8a6eb0e9f3704a0.tar.xz mediagoblin-975be468cfc47e14cafb1b1bc8a6eb0e9f3704a0.zip |
Making the register_themes() tool also return the current theme
This will reduce the amount of work reproducing this behavior when
pulling together the theme registry elsewhere.
-rw-r--r-- | mediagoblin/app.py | 8 | ||||
-rw-r--r-- | mediagoblin/tools/theme.py | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/mediagoblin/app.py b/mediagoblin/app.py index a10edfaa..dfc715b9 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -75,13 +75,7 @@ class MediaGoblinApp(object): self.connection, self.db = setup_database() # Register themes - self.theme_registry = register_themes(app_config) - self.current_theme_name = app_config.get('theme') - if self.current_theme_name \ - and self.theme_registry.has_key(self.current_theme_name): - self.current_theme = self.theme_registry[self.current_theme_name] - else: - self.current_theme = None + self.theme_registry, self.current_theme = register_themes(app_config) # Get the template environment self.template_loader = get_jinja_loader( diff --git a/mediagoblin/tools/theme.py b/mediagoblin/tools/theme.py index dc83e0ff..b19b16df 100644 --- a/mediagoblin/tools/theme.py +++ b/mediagoblin/tools/theme.py @@ -69,11 +69,20 @@ def register_themes(app_config, builtin_dir=BUILTIN_THEME_DIR): registry[themedir] = themedata # Built-in themes - _install_themes_in_dir(builtin_dir) + if os.path.exists(builtin_dir): + _install_themes_in_dir(builtin_dir) # Installed themes theme_install_dir = app_config.get('theme_install_dir') if theme_install_dir and os.path.exists(theme_install_dir): _install_themes_in_dir(theme_install_dir) - return registry + current_theme_name = app_config.get('theme') + if current_theme_name \ + and registry.has_key(current_theme_name): + current_theme = registry[current_theme_name] + else: + current_theme = None + + return registry, current_theme + |