Make regid an optional argument instead of hardcoding special case for index
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 21 Feb 2017 17:46:12 +0100
changeset 120 d70eed2a940e
parent 119 5a38bda4898c
child 123 feb0194f5851
Make regid an optional argument instead of hardcoding special case for index
views/__init__.py
--- a/views/__init__.py	Tue Feb 21 17:45:01 2017 +0100
+++ b/views/__init__.py	Tue Feb 21 17:46:12 2017 +0100
@@ -43,15 +43,14 @@
                             data_url=self._cw.datadir_url))
 
 
-def jinja_static_view(template_name, title=None):
+def jinja_static_view(template_name, title=None, regid=None):
     """Generate a sub-class of JinjaStaticView parametrized with its `template_name` and `title`.
 
     `__regid__` is built by prepending 'sherpa.' to template_name.
     """
     class_name = template_name.capitalize() + 'View'
-    regid = 'sherpa.' + template_name
-    if template_name == 'index':
-        regid = 'index'
+    if regid is None:
+        regid = 'sherpa.' + template_name
 
     return type(class_name, (JinjaStaticView,), {'__regid__': regid,
                                                  'template_name': template_name,
@@ -61,7 +60,7 @@
 ProjectView = jinja_static_view('project', u'Sherpa un générateur de profils')
 UtilisationView = jinja_static_view('utilisation', u'Pour commencer')
 SedaView = jinja_static_view('seda', u'Le SEDA')
-IndexView = jinja_static_view('index')
+IndexView = jinja_static_view('index', regid='index')
 
 
 class SherpaReqRewriter(urlrewrite.SimpleReqRewriter):