696 if need_local_check: |
696 if need_local_check: |
697 # check local role for entities of necessary types |
697 # check local role for entities of necessary types |
698 for i, row in enumerate(rset): |
698 for i, row in enumerate(rset): |
699 if not rset.description[i][0] in need_local_check: |
699 if not rset.description[i][0] in need_local_check: |
700 continue |
700 continue |
701 if not self.score(req, rset, i, col)): |
701 if not self.score(req, rset, i, col): |
702 return 0 |
702 return 0 |
703 score += 1 |
703 score += 1 |
704 return score |
704 return score |
705 return self.score(req, rset, i, col) |
705 return self.score(req, rset, i, col) |
706 |
706 |
899 |
899 |
900 searchstate_accept = deprecated_function(searchstate_accept) |
900 searchstate_accept = deprecated_function(searchstate_accept) |
901 searchstate_accept_one = deprecated_function(searchstate_accept_one) |
901 searchstate_accept_one = deprecated_function(searchstate_accept_one) |
902 |
902 |
903 |
903 |
|
904 def unbind_method(selector): |
|
905 def new_selector(registered): |
|
906 # get the unbound method |
|
907 if hasattr(registered, 'im_func'): |
|
908 registered = registered.im_func |
|
909 return selector(registered) |
|
910 # don't rebind since it will be done automatically during |
|
911 # the assignment, inside the destination class body |
|
912 return plugged_selector |
|
913 new_selector.__name__ = selector.__name__ |
|
914 return new_selector |
|
915 |
|
916 |
|
917 @unbind_method |
904 def require_group_compat(registered): |
918 def require_group_compat(registered): |
905 def plug_selector(cls, vreg): |
919 def plug_selector(cls, vreg): |
906 cls = registered(cls, vreg) |
920 cls = registered(cls, vreg) |
907 if getattr(cls, 'require_groups', None): |
921 if getattr(cls, 'require_groups', None): |
908 warn('use "use match_user_groups(group1, group2)" instead of using require_groups', |
922 warn('use "use match_user_groups(group1, group2)" instead of using require_groups', |
909 DeprecationWarning) |
923 DeprecationWarning) |
910 cls.__selectors__ += (match_user_groups(cls.require_groups),) |
924 cls.__selectors__ += (match_user_groups(cls.require_groups),) |
911 return cls |
925 return cls |
912 return classmethod(plug_selector) |
926 return plug_selector |
913 |
927 |
|
928 @unbind_method |
914 def accepts_compat(registered): |
929 def accepts_compat(registered): |
915 def plug_selector(cls, vreg): |
930 def plug_selector(cls, vreg): |
916 cls = registered(cls, vreg) |
931 cls = registered(cls, vreg) |
917 if getattr(cls, 'accepts', None): |
932 if getattr(cls, 'accepts', None): |
918 warn('use "use match_user_groups(group1, group2)" instead of using require_groups', |
933 warn('use "use match_user_groups(group1, group2)" instead of using require_groups', |
919 DeprecationWarning) |
934 DeprecationWarning) |
920 cls.__selectors__ += (implements(*cls.accepts),) |
935 cls.__selectors__ += (implements(*cls.accepts),) |
921 return cls |
936 return cls |
922 return classmethod(plug_selector) |
937 return plug_selector |
923 |
938 |
|
939 @unbind_method |
924 def condition_compat(registered): |
940 def condition_compat(registered): |
925 def plug_selector(cls, vreg): |
941 def plug_selector(cls, vreg): |
926 cls = registered(cls, vreg) |
942 cls = registered(cls, vreg) |
927 if getattr(cls, 'condition', None): |
943 if getattr(cls, 'condition', None): |
928 warn('use "use rql_condition(expression)" instead of using condition', |
944 warn('use "use rql_condition(expression)" instead of using condition', |
929 DeprecationWarning) |
945 DeprecationWarning) |
930 cls.__selectors__ += (rql_condition(cls.condition),) |
946 cls.__selectors__ += (rql_condition(cls.condition),) |
931 return cls |
947 return cls |
932 return classmethod(plug_selector) |
948 return plug_selector |