diff options
author | Simo Sorce <simo@redhat.com> | 2014-02-18 15:08:12 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2014-02-24 20:30:06 -0500 |
commit | 2a6309cd0f22951b288393f7b70816db94841897 (patch) | |
tree | bc8fb2e19b2d9075c25241a7fc9d8efa8d2ea9d7 /ipsilon/util | |
parent | 126eae3c31dc971e12dadf7856e9f2323c52e33a (diff) | |
download | ipsilon-2a6309cd0f22951b288393f7b70816db94841897.tar.gz ipsilon-2a6309cd0f22951b288393f7b70816db94841897.tar.xz ipsilon-2a6309cd0f22951b288393f7b70816db94841897.zip |
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 <simo@redhat.com>
Diffstat (limited to 'ipsilon/util')
-rwxr-xr-x | ipsilon/util/page.py | 12 |
1 files changed, 11 insertions, 1 deletions
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) |