fix to work with new templates code
authorTero Marttila <terom@fixme.fi>
Mon, 09 Feb 2009 04:38:48 +0200
changeset 47 2cceeb731950
parent 46 73aef9705d6c
child 48 3a1e128c4975
fix to work with new templates code
index.cgi
lookup.py
page.py
--- a/index.cgi	Sun Feb 08 03:38:46 2009 +0200
+++ b/index.cgi	Mon Feb 09 04:38:48 2009 +0200
@@ -34,7 +34,7 @@
         cgi_handler = wsgiref.handlers.CGIHandler()
 
         # create app handler
-        handler = lookup.PageMapper("pages", template=template.TemplateLoader.load("templates/layout.tmpl"))
+        handler = lookup.PageMapper("pages", templates=template.TemplateLoader("templates"))
 
         # create app
         app = wsgi.Application(handler)
--- a/lookup.py	Sun Feb 08 03:38:46 2009 +0200
+++ b/lookup.py	Mon Feb 09 04:38:48 2009 +0200
@@ -16,14 +16,14 @@
         (template.TEMPLATE_EXT,     page.TemplatePage       ),
     ]
 
-    def __init__ (self, path, template) :
+    def __init__ (self, path, templates) :
         """
             Create, path is where the pages are stored. The list of pages is loaded from $path/list
         """
         
         # store
         self.path = path 
-        self.template = template
+        self.templates = templates
 
         # load the page tree
         self.tree = page_tree.PageTree(path + '/list')
--- a/page.py	Sun Feb 08 03:38:46 2009 +0200
+++ b/page.py	Mon Feb 09 04:38:48 2009 +0200
@@ -7,7 +7,7 @@
 import os, os.path
 import time
 
-from qmsk.web import http, handler, template, config
+from qmsk.web import http, handler, config
 
 import menu
 
@@ -99,14 +99,11 @@
         """
 
         # render the template
-        response_data = template.TemplateLoader.render_template(self.fs.template,
+        return self.fs.templates.render_to_response("layout",
             req             = request,
             page            = self,
             menu            = menu.Menu(self.fs, self),
         )
-        
-        # return the response
-        return http.Response(response_data)
 
 class HTMLPage (Page) :
     """
@@ -132,7 +129,7 @@
             Loads the .tmpl file, and renders it
         """
 
-        return template.TemplateLoader.render_file(self.path,
+        return self.fs.templates.render_file(self.path,
             page_tree   = self.fs.tree,
         )