From 0b0acb8388023584d76be38da466b2f098569527 Mon Sep 17 00:00:00 2001 From: peixinchen Date: Tue, 29 Apr 2014 19:43:19 +0800 Subject: [PATCH 1/2] 1. fix bug. 2. add error message. --- flask_themes/__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/flask_themes/__init__.py b/flask_themes/__init__.py index 1a9e14d..d21cd2d 100644 --- a/flask_themes/__init__.py +++ b/flask_themes/__init__.py @@ -52,8 +52,14 @@ def __init__(self, path): #: path. self.path = os.path.abspath(path) - with open(os.path.join(self.path, 'info.json')) as fd: - self.info = i = json.load(fd) + try: + with open(os.path.join(self.path, 'info.json')) as fd: + try: + self.info = i = json.load(fd) + except ValueError, e: + raise path + ": Invalid json format." + except OSError, e: + raise path + ": Could not find `info.json`." #: The theme's name, as given in info.json. This is the human #: readable name. @@ -167,7 +173,7 @@ def load_themes_from(path): try: t = Theme(os.path.join(path, basename)) except: - pass + raise else: if t.identifier == basename: yield t @@ -413,6 +419,10 @@ def active_theme(ctx): @contextfunction def global_theme_template(ctx, templatename, fallback=True): theme = active_theme(ctx) + if USING_BLUEPRINTS: + templatepath = '%s/%s' % (theme, templatename) + else: + templatepath = '_themes/%s/%s' % (theme, templatename) templatepath = '_themes/%s/%s' % (theme, templatename) if (not fallback) or template_exists(templatepath): return templatepath From d9ead9cf20d0a13df748e9dd85fcc2ec3654d94d Mon Sep 17 00:00:00 2001 From: peixinchen Date: Tue, 29 Apr 2014 19:45:11 +0800 Subject: [PATCH 2/2] 1. fix bug --- flask_themes/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/flask_themes/__init__.py b/flask_themes/__init__.py index d21cd2d..d7bf009 100644 --- a/flask_themes/__init__.py +++ b/flask_themes/__init__.py @@ -423,7 +423,6 @@ def global_theme_template(ctx, templatename, fallback=True): templatepath = '%s/%s' % (theme, templatename) else: templatepath = '_themes/%s/%s' % (theme, templatename) - templatepath = '_themes/%s/%s' % (theme, templatename) if (not fallback) or template_exists(templatepath): return templatepath else: