216 |
216 |
217 @property |
217 @property |
218 def name(self): |
218 def name(self): |
219 return self.__class__.name |
219 return self.__class__.name |
220 |
220 |
|
221 # tag_subject_of / tag_object_of issue warning if '*' is not given as target |
|
222 # type, while tag_relation handle it silently since it may be used during |
|
223 # initialization |
221 def tag_subject_of(self, key, tag): |
224 def tag_subject_of(self, key, tag): |
222 subj, rtype, obj = key |
225 subj, rtype, obj = key |
223 if obj != '*': |
226 if obj != '*': |
224 self.warning('using explict target type in %s.tag_subject_of() ' |
227 self.warning('using explict target type in %s.tag_subject_of() ' |
225 'has no effect, use (%s, %s, "*") instead of (%s, %s, %s)', |
228 'has no effect, use (%s, %s, "*") instead of (%s, %s, %s)', |
232 self.warning('using explict subject type in %s.tag_object_of() ' |
235 self.warning('using explict subject type in %s.tag_object_of() ' |
233 'has no effect, use ("*", %s, %s) instead of (%s, %s, %s)', |
236 'has no effect, use ("*", %s, %s) instead of (%s, %s, %s)', |
234 self.name, rtype, obj, subj, rtype, obj) |
237 self.name, rtype, obj, subj, rtype, obj) |
235 super(NoTargetRelationTagsDict, self).tag_object_of(('*', rtype, obj), tag) |
238 super(NoTargetRelationTagsDict, self).tag_object_of(('*', rtype, obj), tag) |
236 |
239 |
237 |
240 def tag_relation(self, key, tag): |
|
241 if key[-1] == 'subject' and key[-2] != '*': |
|
242 if isinstance(key, tuple): |
|
243 key = list(key) |
|
244 key[-2] = '*' |
|
245 elif key[-1] == 'object' and key[0] != '*': |
|
246 if isinstance(key, tuple): |
|
247 key = list(key) |
|
248 key[0] = '*' |
|
249 super(NoTargetRelationTagsDict, self).tag_relation(key, tag) |
238 set_log_methods(RelationTags, logging.getLogger('cubicweb.rtags')) |
250 set_log_methods(RelationTags, logging.getLogger('cubicweb.rtags')) |