selectors.py
changeset 2788 8d3dbe577d3a
parent 2657 de974465d381
child 2797 de0fcdb65e30
equal deleted inserted replaced
2787:ece5bbed3cd2 2788:8d3dbe577d3a
   961     def __init__(self, scorefunc, once_is_enough=False):
   961     def __init__(self, scorefunc, once_is_enough=False):
   962         super(score_entity, self).__init__(once_is_enough)
   962         super(score_entity, self).__init__(once_is_enough)
   963         self.score_entity = scorefunc
   963         self.score_entity = scorefunc
   964 
   964 
   965 
   965 
   966 # XXX DEPRECATED ##############################################################
   966 # XXX DEPRECATED in 3.4 ########################################################
   967 from cubicweb.vregistry import chainall
   967 from cubicweb.vregistry import chainall
   968 
   968 
   969 yes_selector = deprecated()(yes)
   969 yes_selector = deprecated()(yes)
   970 norset_selector = deprecated()(none_rset)
   970 norset_selector = deprecated()(none_rset)
   971 rset_selector = deprecated()(any_rset)
   971 rset_selector = deprecated()(any_rset)
   981 anonymous_selector = deprecated()(anonymous_user)
   981 anonymous_selector = deprecated()(anonymous_user)
   982 not_anonymous_selector = deprecated()(authenticated_user)
   982 not_anonymous_selector = deprecated()(authenticated_user)
   983 primaryview_selector = deprecated()(primary_view)
   983 primaryview_selector = deprecated()(primary_view)
   984 contextprop_selector = deprecated()(match_context_prop)
   984 contextprop_selector = deprecated()(match_context_prop)
   985 
   985 
   986 @deprecated('use non_final_entity instead of %s')
   986 @deprecated('[3.4] use non_final_entity instead of %s')
   987 def nfentity_selector(cls, req, rset=None, row=None, col=0, **kwargs):
   987 def nfentity_selector(cls, req, rset=None, row=None, col=0, **kwargs):
   988     return non_final_entity()(cls, req, rset, row, col)
   988     return non_final_entity()(cls, req, rset, row, col)
   989 
   989 
   990 @deprecated('use implements instead of %s')
   990 @deprecated('[3.4] use implements instead of %s')
   991 def implement_interface(cls, req, rset=None, row=None, col=0, **kwargs):
   991 def implement_interface(cls, req, rset=None, row=None, col=0, **kwargs):
   992     return implements(*cls.accepts_interfaces)(cls, req, rset, row, col)
   992     return implements(*cls.accepts_interfaces)(cls, req, rset, row, col)
   993 _interface_selector = deprecated()(implement_interface)
   993 _interface_selector = deprecated()(implement_interface)
   994 interface_selector = deprecated()(implement_interface)
   994 interface_selector = deprecated()(implement_interface)
   995 
   995 
   996 @deprecated('use specified_etype_implements instead of %s')
   996 @deprecated('[3.4] use specified_etype_implements instead of %s')
   997 def accept_etype(cls, req, *args, **kwargs):
   997 def accept_etype(cls, req, *args, **kwargs):
   998     """check etype presence in request form *and* accepts conformance"""
   998     """check etype presence in request form *and* accepts conformance"""
   999     return specified_etype_implements(*cls.accepts)(cls, req, *args)
   999     return specified_etype_implements(*cls.accepts)(cls, req, *args)
  1000 etype_form_selector = accept_etype
  1000 etype_form_selector = accept_etype
  1001 
  1001 
  1002 @deprecated('use match_search_state instead of %s')
  1002 @deprecated('[3.4] use match_search_state instead of %s')
  1003 def searchstate_selector(cls, req, rset=None, row=None, col=0, **kwargs):
  1003 def searchstate_selector(cls, req, rset=None, row=None, col=0, **kwargs):
  1004     return match_search_state(cls.search_states)(cls, req, rset, row, col)
  1004     return match_search_state(cls.search_states)(cls, req, rset, row, col)
  1005 
  1005 
  1006 @deprecated('use match_user_groups instead of %s')
  1006 @deprecated('[3.4] use match_user_groups instead of %s')
  1007 def match_user_group(cls, req, rset=None, row=None, col=0, **kwargs):
  1007 def match_user_group(cls, req, rset=None, row=None, col=0, **kwargs):
  1008     return match_user_groups(*cls.require_groups)(cls, req, rset, row, col, **kwargs)
  1008     return match_user_groups(*cls.require_groups)(cls, req, rset, row, col, **kwargs)
  1009 in_group_selector = match_user_group
  1009 in_group_selector = match_user_group
  1010 
  1010 
  1011 @deprecated('use relation_possible instead of %s')
  1011 @deprecated('[3.4] use relation_possible instead of %s')
  1012 def has_relation(cls, req, rset=None, row=None, col=0, **kwargs):
  1012 def has_relation(cls, req, rset=None, row=None, col=0, **kwargs):
  1013     return relation_possible(cls.rtype, role(cls), cls.etype,
  1013     return relation_possible(cls.rtype, role(cls), cls.etype,
  1014                              getattr(cls, 'require_permission', 'read'))(cls, req, rset, row, col, **kwargs)
  1014                              getattr(cls, 'require_permission', 'read'))(cls, req, rset, row, col, **kwargs)
  1015 
  1015 
  1016 @deprecated('use relation_possible instead of %s')
  1016 @deprecated('[3.4] use relation_possible instead of %s')
  1017 def one_has_relation(cls, req, rset=None, row=None, col=0, **kwargs):
  1017 def one_has_relation(cls, req, rset=None, row=None, col=0, **kwargs):
  1018     return relation_possible(cls.rtype, role(cls), cls.etype,
  1018     return relation_possible(cls.rtype, role(cls), cls.etype,
  1019                              getattr(cls, 'require_permission', 'read',
  1019                              getattr(cls, 'require_permission', 'read',
  1020                                      once_is_enough=True))(cls, req, rset, row, col, **kwargs)
  1020                                      once_is_enough=True))(cls, req, rset, row, col, **kwargs)
  1021 
  1021 
  1022 @deprecated('use implements instead of %s')
  1022 @deprecated('[3.4] use implements instead of %s')
  1023 def accept_rset(cls, req, rset=None, row=None, col=0, **kwargs):
  1023 def accept_rset(cls, req, rset=None, row=None, col=0, **kwargs):
  1024     """simply delegate to cls.accept_rset method"""
  1024     """simply delegate to cls.accept_rset method"""
  1025     return implements(*cls.accepts)(cls, req, rset, row=row, col=col)
  1025     return implements(*cls.accepts)(cls, req, rset, row=row, col=col)
  1026 accept_rset_selector = accept_rset
  1026 accept_rset_selector = accept_rset
  1027 
  1027 
  1028 accept = chainall(non_final_entity(), accept_rset, name='accept')
  1028 accept = chainall(non_final_entity(), accept_rset, name='accept')
  1029 accept = deprecated('use implements selector')(accept)
  1029 accept = deprecated('[3.4] use implements selector')(accept)
  1030 accept_selector = deprecated()(accept)
  1030 accept_selector = deprecated()(accept)
  1031 
  1031 
  1032 accept_one = deprecated()(chainall(one_line_rset, accept,
  1032 accept_one = deprecated()(chainall(one_line_rset, accept,
  1033                                    name='accept_one'))
  1033                                    name='accept_one'))
  1034 accept_one_selector = deprecated()(accept_one)
  1034 accept_one_selector = deprecated()(accept_one)
  1041 _rqlcondition_selector = deprecated()(_rql_condition)
  1041 _rqlcondition_selector = deprecated()(_rql_condition)
  1042 
  1042 
  1043 rqlcondition_selector = deprecated()(chainall(non_final_entity(), one_line_rset, _rql_condition,
  1043 rqlcondition_selector = deprecated()(chainall(non_final_entity(), one_line_rset, _rql_condition,
  1044                          name='rql_condition'))
  1044                          name='rql_condition'))
  1045 
  1045 
  1046 @deprecated('use but_etype instead of %s')
  1046 @deprecated('[3.4] use but_etype instead of %s')
  1047 def but_etype_selector(cls, req, rset=None, row=None, col=0, **kwargs):
  1047 def but_etype_selector(cls, req, rset=None, row=None, col=0, **kwargs):
  1048     return but_etype(cls.etype)(cls, req, rset, row, col)
  1048     return but_etype(cls.etype)(cls, req, rset, row, col)
  1049 
  1049 
  1050 @lltrace
  1050 @lltrace
  1051 def etype_rtype_selector(cls, req, rset=None, row=None, col=0, **kwargs):
  1051 def etype_rtype_selector(cls, req, rset=None, row=None, col=0, **kwargs):