[views] Don't put url in a specific module
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Feb 2017 14:21:43 +0100
changeset 62 eec896494026
parent 61 43b191bd84aa
child 63 2f055b10dbce
[views] Don't put url in a specific module It's simpler to have them in package's init.
views/__init__.py
views/urls.py
--- a/views/__init__.py	Fri Feb 03 14:20:48 2017 +0100
+++ b/views/__init__.py	Fri Feb 03 14:21:43 2017 +0100
@@ -18,6 +18,7 @@
 
 from cubicweb import _
 from cubicweb.view import View
+from cubicweb.web.views import urlrewrite
 
 _JINJA_ENV = Environment(loader=PackageLoader('cubes.sherpa.views'))
 
@@ -56,3 +57,11 @@
 ProjectView = jinja_static_view('project', _('Le projet Sherpa'))
 UtilisationView = jinja_static_view('utilisation', _("Mode d'emploi"))
 SedaView = jinja_static_view('seda', _('Le SEDA'))
+
+
+class SherpaReqRewriter(urlrewrite.SimpleReqRewriter):
+    rules = [
+        (urlrewrite.rgx('/project'), dict(vid='sherpa.project')),
+        (urlrewrite.rgx('/utilisation'), dict(vid='sherpa.utilisation')),
+        (urlrewrite.rgx('/seda'), dict(vid='sherpa.seda'))
+    ]
--- a/views/urls.py	Fri Feb 03 14:20:48 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-from cubicweb.web.views.urlrewrite import SimpleReqRewriter, rgx
-
-
-class SherpaReqRewriter(SimpleReqRewriter):
-    rules = [
-        (rgx('/project'), dict(vid='sherpa-project')),
-        (rgx('/utilisation'), dict(vid='sherpa-utilisation')),
-        (rgx('/seda'), dict(vid='sherpa-seda'))
-    ]
-
-
-def registration_callback(vreg):
-    vreg.register(SherpaReqRewriter)