Mercurial > hg > decoupage
changeset 20:c17595c824a7
try to fail gracefully if index.html exists
author | egj@egj-laptop |
---|---|
date | Sun, 03 Jan 2010 15:36:14 -0500 |
parents | d2e519a2f13c |
children | 64ae0d2f402b |
files | decoupage/web.py |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/decoupage/web.py Sun Jan 03 19:45:21 2010 +0000 +++ b/decoupage/web.py Sun Jan 03 15:36:14 2010 -0500 @@ -122,9 +122,11 @@ # render the template template = conf.get('/template') + local_index = False if template is None: if 'index.html' in [ f['name'] for f in files ]: - template = os.path.join(directory, 'index.html') + local_index = os.path.join(directory, 'index.html') + template = local_index else: template = self.template else: @@ -140,7 +142,13 @@ raise IOError("template %s not found" % template) template = self.loader.load(template) - res = template.generate(**data).render('html', doctype='html') + try: + res = template.generate(**data).render('html', doctype='html') + except TemplateSyntaxError: + if local_index: + return self.fileserver(local_index) + raise + return self.get_response(res) ### internal methods