cubicweb/pyramid/predicates.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 21 Feb 2017 11:04:19 +0100
branch3.25
changeset 12141 29d032bb70d8
parent 11967 83739be20fab
child 12890 0cd5b9057202
permissions -rw-r--r--
Add a "Contributing" section to README with patch submission guidelines For the CubicWeb project and its dependencies, we now prefer patches submission and review by email on a public mailing list. We are thus moving away from the previous vcreview-based workflow taking place on the forge. This change is motivated by the following points: - the current reviewer assignment mechanism (pick a random reviewer, rely on reviewer availability rather than on willingness to review, send related patches to distinct people, etc.) is inefficient if not counter-productive; - most of the times, discussion only happens between the patch submitter and a reviewer with no easy way to increase the audience; - cubicweb-vcreview has no concept of patch series; - cubicweb-vcreview is not actively maintained anymore and its usability keeps deteriorating. We expect that email-based submission and review of patches will circumvent these limitations. Anybody interested in the project is welcome to subscribed to the mailing list and participate to the review process. This patch documents the basic workflow of patches submissions by email.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)