# HG changeset patch # User egj@egj-laptop # Date 1262550974 18000 # Node ID c17595c824a75cdfdb18f7cb0f7b13d4ac0cb065 # Parent d2e519a2f13c7da1185d6d3ee0cf07421c4d2caa try to fail gracefully if index.html exists diff -r d2e519a2f13c -r c17595c824a7 decoupage/web.py --- 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