35
35
def __init__(self, req, **kwargs):
37
37
setattr(self, key, kwargs[key])
39
39
def render(self, req):
40
40
req.content_type = 'text/html' # TODO: Detect application/xhtml+xml
41
ctx = genshi.template.Context()
42
self.populate(req, ctx)
43
self.populate_headings(req, ctx)
45
ctx['app_styles'] = req.styles
46
ctx['scripts'] = req.scripts
47
ctx['scripts_init'] = req.scripts_init
43
viewctx = genshi.template.Context()
44
self.populate(req, viewctx)
46
# The template is found in the directory of the module containing the
48
48
app_template = os.path.join(os.path.dirname(
49
49
inspect.getmodule(self).__file__), self.template)
50
50
req.write_html_head_foot = False
51
51
loader = genshi.template.TemplateLoader(".", auto_reload=True)
52
52
tmpl = loader.load(app_template)
53
app = tmpl.generate(ctx)
53
app = tmpl.generate(viewctx)
56
ctx = genshi.template.Context()
57
ctx['app_styles'] = req.styles
58
ctx['scripts'] = req.scripts
59
ctx['scripts_init'] = req.scripts_init
54
60
ctx['app_template'] = app
61
self.populate_headings(req, ctx)
55
62
tmpl = loader.load(os.path.join(os.path.dirname(__file__),
56
63
'ivle-headings.html'))
57
64
req.write(tmpl.generate(ctx).render('xhtml', doctype='xhtml'))