# HG changeset patch # User Rabah Meradi # Date 1437737958 -7200 # Node ID 473754eac7c19ee273deafad8bc296946077545d # Parent f8ba6ea94af934d1af11155d70c44e0c3bd1fad2 [refactoring] Move MatchIsETypePredicate to a separate module diff -r f8ba6ea94af9 -r 473754eac7c1 pyramid_cubicweb/predicates.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pyramid_cubicweb/predicates.py Fri Jul 24 13:39:18 2015 +0200 @@ -0,0 +1,18 @@ +"""Contains predicates used in Pyramid views. +""" + + +class MatchIsETypePredicate(object): + """A predicate that match if a given etype exist in schema. + """ + def __init__(self, matchname, config): + self.matchname = matchname + + def text(self): + return 'match_is_etype = %s' % self.matchname + + phash = text + + def __call__(self, info, request): + return info['match'][self.matchname].lower() in \ + request.registry['cubicweb.registry'].case_insensitive_etypes diff -r f8ba6ea94af9 -r 473754eac7c1 pyramid_cubicweb/rest_api.py --- a/pyramid_cubicweb/rest_api.py Fri Jul 24 13:40:36 2015 +0200 +++ b/pyramid_cubicweb/rest_api.py Fri Jul 24 13:39:18 2015 +0200 @@ -4,22 +4,7 @@ from pyramid.httpexceptions import HTTPNotFound from pyramid.view import view_config from pyramid_cubicweb.resources import EntityResource, ETypeResource - - -class MatchIsETypePredicate(object): - def __init__(self, matchname, config): - self.matchname = matchname - self.etypes = frozenset( - k.lower() for k in config.registry['cubicweb.registry']['etypes']) - - def text(self): - return 'match_is_etype = %s' % self.matchname - - phash = text - - def __call__(self, info, request): - return info['match'][self.matchname].lower() in \ - request.registry['cubicweb.registry'].case_insensitive_etypes +from pyramid_cubicweb.predicates import MatchIsETypePredicate @view_config(