Move default template arguments to its own function
authorSimo Sorce <simo@redhat.com>
Tue, 18 Feb 2014 20:08:12 +0000 (15:08 -0500)
committerSimo Sorce <simo@redhat.com>
Tue, 25 Feb 2014 01:30:06 +0000 (20:30 -0500)
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>
ipsilon/util/page.py

index 0da0e37..2cdca1c 100755 (executable)
@@ -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)