From: Simo Sorce Date: Tue, 18 Feb 2014 20:08:12 +0000 (-0500) Subject: Move default template arguments to its own function X-Git-Tag: v0.2.2~98 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=commitdiff_plain;h=2a6309cd0f22951b288393f7b70816db94841897 Move default template arguments to its own function This way it is clearer what the defaults are, plus subclasses can override the defaults if they so choose. Signed-off-by: Simo Sorce --- diff --git a/ipsilon/util/page.py b/ipsilon/util/page.py index 0da0e37..2cdca1c 100755 --- a/ipsilon/util/page.py +++ b/ipsilon/util/page.py @@ -48,9 +48,19 @@ class Page(object): return self.default(*args, **kwargs) + def _template_model(self): + model = dict() + model['basepath'] = self.basepath + model['title'] = 'IPSILON' + model['user'] = self.user + return model + def _template(self, *args, **kwargs): + # pylint: disable=star-args t = self._site['template_env'].get_template(args[0]) - return t.render(basepath=self.basepath, user=self.user, **kwargs) + m = self._template_model() + m.update(kwargs) + return t.render(**m) def default(self, *args, **kwargs): raise cherrypy.HTTPError(404)