author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Fri, 06 Oct 2017 11:45:52 +0200 | |
branch | 3.25 |
changeset 12207 | 2fc04786dd36 |
parent 11967 | 83739be20fab |
child 12890 | 0cd5b9057202 |
permissions | -rw-r--r-- |
11967
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
1 |
# copyright 2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
2 |
# copyright 2014-2016 UNLISH S.A.S. (Montpellier, FRANCE), all rights reserved. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
3 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
4 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
5 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
6 |
# This file is part of CubicWeb. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
7 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
8 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
9 |
# terms of the GNU Lesser General Public License as published by the Free |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
10 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
11 |
# any later version. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
12 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
13 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
14 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
15 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
16 |
# details. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
17 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
18 |
# You should have received a copy of the GNU Lesser General Public License along |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
19 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11631
diff
changeset
|
20 |
|
11600
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
21 |
"""Contains predicates used in Pyramid views. |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
22 |
""" |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
23 |
|
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
24 |
|
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
25 |
class MatchIsETypePredicate(object): |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
26 |
"""A predicate that match if a given etype exist in schema. |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
27 |
""" |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
28 |
def __init__(self, matchname, config): |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
29 |
self.matchname = matchname |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
30 |
|
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
31 |
def text(self): |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
32 |
return 'match_is_etype = %s' % self.matchname |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
33 |
|
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
34 |
phash = text |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
35 |
|
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
36 |
def __call__(self, info, request): |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
37 |
return info['match'][self.matchname].lower() in \ |
473754eac7c1
[refactoring] Move MatchIsETypePredicate to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
diff
changeset
|
38 |
request.registry['cubicweb.registry'].case_insensitive_etypes |
11601
23a62d151382
Register predicates from the predicates module
Christophe de Vienne <cdevienne@gmail.com>
parents:
11600
diff
changeset
|
39 |
|
23a62d151382
Register predicates from the predicates module
Christophe de Vienne <cdevienne@gmail.com>
parents:
11600
diff
changeset
|
40 |
|
23a62d151382
Register predicates from the predicates module
Christophe de Vienne <cdevienne@gmail.com>
parents:
11600
diff
changeset
|
41 |
def includeme(config): |
23a62d151382
Register predicates from the predicates module
Christophe de Vienne <cdevienne@gmail.com>
parents:
11600
diff
changeset
|
42 |
config.add_route_predicate('match_is_etype', MatchIsETypePredicate) |