# HG changeset patch # User Sylvain Thénault # Date 1296110648 -3600 # Node ID fcd4e6beec090a4535fcb0e737cf49064dffd0a2 # Parent e592fb8ee27b0907106d563d80cecd412633fda7 [rtags] fix NoTargetRelationTagsDict to ensure relation are tagged using '*' during initialization diff -r e592fb8ee27b -r fcd4e6beec09 rtags.py --- a/rtags.py Thu Jan 27 07:42:18 2011 +0100 +++ b/rtags.py Thu Jan 27 07:44:08 2011 +0100 @@ -218,6 +218,9 @@ def name(self): return self.__class__.name + # tag_subject_of / tag_object_of issue warning if '*' is not given as target + # type, while tag_relation handle it silently since it may be used during + # initialization def tag_subject_of(self, key, tag): subj, rtype, obj = key if obj != '*': @@ -234,5 +237,14 @@ self.name, rtype, obj, subj, rtype, obj) super(NoTargetRelationTagsDict, self).tag_object_of(('*', rtype, obj), tag) - + def tag_relation(self, key, tag): + if key[-1] == 'subject' and key[-2] != '*': + if isinstance(key, tuple): + key = list(key) + key[-2] = '*' + elif key[-1] == 'object' and key[0] != '*': + if isinstance(key, tuple): + key = list(key) + key[0] = '*' + super(NoTargetRelationTagsDict, self).tag_relation(key, tag) set_log_methods(RelationTags, logging.getLogger('cubicweb.rtags'))