diff options
Diffstat (limited to 'renderer.py')
-rw-r--r-- | renderer.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/renderer.py b/renderer.py deleted file mode 100644 index 0c14327..0000000 --- a/renderer.py +++ /dev/null @@ -1,40 +0,0 @@ -import os -import web -import mako -from mako.lookup import TemplateLookup - -import helper - -class Renderer: - """ - Renderer loading the correct Mako Templates - """ - def __init__ (self): - self.lookup = TemplateLookup( - directories=[helper.appdir('templates')], - module_directory = "/tmp/webpy/kosten/", - input_encoding='utf-8', - output_encoding='utf-8', - format_exceptions = True) - - def render (self, tpl, level = "pages", **kwargs): - web.header("Content-Type", "text/html;charset=utf-8") - try: - t = self.get_tpl(tpl, level) - except mako.exceptions.TopLevelLookupException, e: - raise web.ctx.app_stack[-1].notfound(tpl) - - return t.render(h = helper, eur = helper.eur, url = helper.url, w = web, **kwargs) - - __call__ = render - - def get_tpl (self, tpl, level = ""): - if not tpl.endswith(".mako"): - tpl = tpl+".mako" - - tpl = os.path.join(level, tpl) - - return self.lookup.get_template(tpl) - -# the one and only instance :) -render = Renderer() |