diff roundup/cgi/engine_chameleon.py @ 4740:fe9568a6cbd6

Untangle template selection logic from template loading functionality.
author anatoly techtonik <techtonik@gmail.com>
date Tue, 15 Jan 2013 00:10:01 +0300
parents 94be76e04140
children 0421390b3094
line wrap: on
line diff
--- a/roundup/cgi/engine_chameleon.py	Mon Jan 14 20:25:00 2013 +0300
+++ b/roundup/cgi/engine_chameleon.py	Tue Jan 15 00:10:01 2013 +0300
@@ -5,15 +5,22 @@
 import os.path
 import chameleon
 
-from roundup.cgi.templating import StringIO, context, find_template, LoaderBase
+from roundup.cgi.templating import StringIO, context, LoaderBase
 
 class Loader(LoaderBase):
     def __init__(self, dir):
         self.dir = dir
         self.loader = chameleon.PageTemplateLoader(dir)
 
-    def load(self, name, view=None):
-        src, filename = find_template(self.dir, name, view)
+    def check(self, name):
+        for extension in ['', '.html', '.xml']:
+            f = name + extension
+            src = os.path.join(self.dir, f)
+            if os.path.exists(src):
+                return (src, f)
+
+    def load(self, tplname):
+        src, filename = self.check(tplname)
         return RoundupPageTemplate(self.loader.load(src))
 
 class RoundupPageTemplate(object):

Roundup Issue Tracker: http://roundup-tracker.org/