rtags.py
branchstable
changeset 6246 62e25fac41cd
parent 6240 fd0cbb801007
child 6899 e592fb8ee27b
--- a/rtags.py	Wed Sep 15 11:13:17 2010 +0200
+++ b/rtags.py	Wed Sep 15 15:00:04 2010 +0200
@@ -210,4 +210,27 @@
     _allowed_values = frozenset((True, False))
 
 
+class NoTargetRelationTagsDict(RelationTagsDict):
+
+    @property
+    def name(self):
+        return self.__class__.name
+
+    def tag_subject_of(self, key, tag):
+        subj, rtype, obj = key
+        if obj != '*':
+            self.warning('using explict target type in %s.tag_subject_of() '
+                         'has no effect, use (%s, %s, "*") instead of (%s, %s, %s)',
+                         self.name, subj, rtype, subj, rtype, obj)
+        super(NoTargetRelationTagsDict, self).tag_subject_of((subj, rtype, '*'), tag)
+
+    def tag_object_of(self, key, tag):
+        subj, rtype, obj = key
+        if subj != '*':
+            self.warning('using explict subject type in %s.tag_object_of() '
+                         'has no effect, use ("*", %s, %s) instead of (%s, %s, %s)',
+                         self.name, rtype, obj, subj, rtype, obj)
+        super(NoTargetRelationTagsDict, self).tag_object_of(('*', rtype, obj), tag)
+
+
 set_log_methods(RelationTags, logging.getLogger('cubicweb.rtags'))