has_relation selector compat, fix some deprecation msg tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 13:26:24 +0100
branchtls-sprint
changeset 654 36e87179e91d
parent 653 189877d9547d
child 655 ca3c4992c7d1
has_relation selector compat, fix some deprecation msg
selectors.py
--- a/selectors.py	Tue Feb 17 12:52:50 2009 +0100
+++ b/selectors.py	Tue Feb 17 13:26:24 2009 +0100
@@ -919,7 +919,7 @@
     def plug_selector(cls, vreg):
         cls = registered(cls, vreg)
         if getattr(cls, 'require_groups', None):
-            warn('use "use match_user_groups(group1, group2)" instead of using require_groups',
+            warn('use "match_user_groups(group1, group2)" instead of using require_groups',
                  DeprecationWarning)
             cls.__selectors__ += (match_user_groups(cls.require_groups),)
         return cls
@@ -930,7 +930,7 @@
     def plug_selector(cls, vreg):
         cls = registered(cls, vreg)
         if getattr(cls, 'accepts', None):
-            warn('use "use match_user_groups(group1, group2)" instead of using require_groups',
+            warn('use "match_user_groups(group1, group2)" instead of using require_groups',
                  DeprecationWarning)
             cls.__selectors__ += (implements(*cls.accepts),)
         return cls
@@ -946,3 +946,16 @@
             cls.__selectors__ += (rql_condition(cls.condition),)
         return cls
     return plug_selector
+     
+@unbind_method
+def has_relation_compat(registered):
+    def plug_selector(cls, vreg):
+        cls = registered(cls, vreg)
+        if getattr(cls, 'type', None):
+            warn('use relation_possible selector instead of using etype_rtype',
+                 DeprecationWarning)
+            cls.__selectors__ += (relation_possible(cls.rtype), role(cls),
+                                  getattr(cls, 'etype', None),
+                                  action=getattr(cls, 'require_permission', 'read'))
+        return cls
+    return plug_selector