[saem-devel] [PATCH sherpa] Make regid an optional argument instead of hardcoding special case for index

Philippe Pepiot philippe.pepiot at logilab.fr
Tue Feb 21 18:19:38 CET 2017


On 02/21/2017 05:46 PM, Sylvain Thenault wrote:

> # HG changeset patch
> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
> # Date 1487695572 -3600
> #      Tue Feb 21 17:46:12 2017 +0100
> # Node ID d70eed2a940e5c99ef57e0f6786d565027afc03c
> # Parent  5a38bda4898cc3f3d7a5d6c00c0fe58a5dc07707
> Make regid an optional argument instead of hardcoding special case for index
>
> diff --git a/views/__init__.py b/views/__init__.py
> --- a/views/__init__.py
> +++ b/views/__init__.py
> @@ -41,29 +41,28 @@ class JinjaStaticView(View):
>           self.w(jinja_render(self.template_name,
>                               title=self._cw._(self.title),
>                               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,
>                                                    'title': title})
>   
>   
>   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):
>       rules = [
>           (urlrewrite.rgx('/'), dict(vid='sherpa.index')),

LGTM

-- 
Philippe Pepiot
https://www.logilab.fr



More information about the saem-devel mailing list