author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 13 Oct 2009 12:03:24 +0200 | |
changeset 3652 | 9fba30110377 |
parent 3485 | e867ae952fc0 |
child 4252 | 6c4f109c2b03 |
permissions | -rw-r--r-- |
1152 | 1 |
"""relation tags store |
2 |
||
3 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1859
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1152 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1859
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
1152 | 7 |
""" |
8 |
__docformat__ = "restructuredtext en" |
|
1148
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
9 |
|
1740
2292ae32c98f
warn and drop rtags not in schema, this may be intentional; drop possibility to not specify value for bool rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
10 |
import logging |
2292ae32c98f
warn and drop rtags not in schema, this may be intentional; drop possibility to not specify value for bool rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
11 |
|
2292ae32c98f
warn and drop rtags not in schema, this may be intentional; drop possibility to not specify value for bool rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
12 |
from logilab.common.logging_ext import set_log_methods |
2292ae32c98f
warn and drop rtags not in schema, this may be intentional; drop possibility to not specify value for bool rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
13 |
|
1752
4b0b912ff5b7
fix rtags initialization: do it at the registry level to avoid multiple initialization of the same rtag
sylvain.thenault@logilab.fr
parents:
1748
diff
changeset
|
14 |
RTAGS = [] |
4b0b912ff5b7
fix rtags initialization: do it at the registry level to avoid multiple initialization of the same rtag
sylvain.thenault@logilab.fr
parents:
1748
diff
changeset
|
15 |
def register_rtag(rtag): |
4b0b912ff5b7
fix rtags initialization: do it at the registry level to avoid multiple initialization of the same rtag
sylvain.thenault@logilab.fr
parents:
1748
diff
changeset
|
16 |
RTAGS.append(rtag) |
1533 | 17 |
|
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
18 |
def _ensure_str_key(key): |
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
19 |
return tuple(str(k) for k in key) |
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
20 |
|
1148
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
21 |
class RelationTags(object): |
1533 | 22 |
"""a tag store for full relation definitions : |
1148
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
23 |
|
1533 | 24 |
(subject type, relation type, object type, tagged) |
1152 | 25 |
|
26 |
allowing to set tags using wildcard (eg '*') as subject type / object type |
|
27 |
||
1533 | 28 |
This class associates a single tag to each key. |
1152 | 29 |
""" |
1739 | 30 |
_allowed_values = None |
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
31 |
_initfunc = None |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1769
diff
changeset
|
32 |
def __init__(self, name=None, initfunc=None, allowed_values=None): |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1769
diff
changeset
|
33 |
self._name = name or '<unknown>' |
1148
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
34 |
self._tagdefs = {} |
1739 | 35 |
if allowed_values is not None: |
36 |
self._allowed_values = allowed_values |
|
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
37 |
if initfunc is not None: |
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
38 |
self._initfunc = initfunc |
1752
4b0b912ff5b7
fix rtags initialization: do it at the registry level to avoid multiple initialization of the same rtag
sylvain.thenault@logilab.fr
parents:
1748
diff
changeset
|
39 |
register_rtag(self) |
1769
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
40 |
|
1528
864ae7c15ef5
other fixlets
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1451
diff
changeset
|
41 |
def __repr__(self): |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1769
diff
changeset
|
42 |
return '%s: %s' % (self._name, repr(self._tagdefs)) |
1528
864ae7c15ef5
other fixlets
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1451
diff
changeset
|
43 |
|
1533 | 44 |
# dict compat |
45 |
def __getitem__(self, key): |
|
46 |
return self.get(*key) |
|
47 |
__contains__ = __getitem__ |
|
1451 | 48 |
|
2689
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2369
diff
changeset
|
49 |
def clear(self): |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2369
diff
changeset
|
50 |
self._tagdefs.clear() |
44f041222d0f
[autoreload] handle uicfg reloading properly with the new event / callback mechanism
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2369
diff
changeset
|
51 |
|
1739 | 52 |
def _get_keys(self, stype, rtype, otype, tagged): |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
53 |
keys = [('*', rtype, '*', tagged), |
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
54 |
('*', rtype, otype, tagged), |
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
55 |
(stype, rtype, '*', tagged), |
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
56 |
(stype, rtype, otype, tagged)] |
1533 | 57 |
if stype == '*' or otype == '*': |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
58 |
keys.remove( ('*', rtype, '*', tagged) ) |
1533 | 59 |
if stype == '*': |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
60 |
keys.remove( ('*', rtype, otype, tagged) ) |
1533 | 61 |
if otype == '*': |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
62 |
keys.remove( (stype, rtype, '*', tagged) ) |
1533 | 63 |
return keys |
1451 | 64 |
|
1769
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
65 |
def init(self, schema, check=True): |
1739 | 66 |
# XXX check existing keys against schema |
1769
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
67 |
if check: |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
68 |
for (stype, rtype, otype, tagged), value in self._tagdefs.items(): |
1769
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
69 |
for ertype in (stype, rtype, otype): |
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
70 |
if ertype != '*' and not ertype in schema: |
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
71 |
self.warning('removing rtag %s: %s, %s undefined in schema', |
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
72 |
(stype, rtype, otype, tagged), value, ertype) |
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
73 |
self.del_rtag(stype, rtype, otype, tagged) |
fb91d2b8a441
fix some rtags pb on i18n catalog generation
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
74 |
break |
1739 | 75 |
if self._initfunc is not None: |
76 |
for eschema in schema.entities(): |
|
77 |
for rschema, tschemas, role in eschema.relation_definitions(True): |
|
78 |
for tschema in tschemas: |
|
79 |
if role == 'subject': |
|
1744 | 80 |
sschema, oschema = eschema, tschema |
1739 | 81 |
else: |
1744 | 82 |
sschema, oschema = tschema, eschema |
83 |
self._initfunc(self, sschema, rschema, oschema, role) |
|
1739 | 84 |
|
85 |
# rtag declaration api #################################################### |
|
86 |
||
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
87 |
def tag_attribute(self, key, *args, **kwargs): |
1739 | 88 |
key = list(key) |
89 |
key.append('*') |
|
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
90 |
self.tag_subject_of(key, *args, **kwargs) |
1548
bd225e776739
new tag_attribute convenience method
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
91 |
|
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
92 |
def tag_subject_of(self, key, *args, **kwargs): |
1739 | 93 |
key = list(key) |
94 |
key.append('subject') |
|
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
95 |
self.tag_relation(key, *args, **kwargs) |
1739 | 96 |
|
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
97 |
def tag_object_of(self, key, *args, **kwargs): |
1739 | 98 |
key = list(key) |
99 |
key.append('object') |
|
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
100 |
self.tag_relation(key, *args, **kwargs) |
1533 | 101 |
|
1739 | 102 |
def tag_relation(self, key, tag): |
103 |
if self._allowed_values is not None: |
|
1859
b068abd45a1c
nicer error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1849
diff
changeset
|
104 |
assert tag in self._allowed_values, \ |
b068abd45a1c
nicer error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1849
diff
changeset
|
105 |
'%r is not an allowed tag (should be in %s)' % ( |
b068abd45a1c
nicer error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1849
diff
changeset
|
106 |
tag, self._allowed_values) |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
107 |
self._tagdefs[_ensure_str_key(key)] = tag |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
108 |
return tag |
1533 | 109 |
|
1739 | 110 |
# rtag runtime api ######################################################## |
111 |
||
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
112 |
def del_rtag(self, *key): |
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
113 |
del self._tagdefs[key] |
1739 | 114 |
|
3473
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
115 |
def get(self, *key): |
d8bc02158efc
[rtags] ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3472
diff
changeset
|
116 |
for key in reversed(self._get_keys(*key)): |
1148
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
117 |
try: |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
118 |
return self._tagdefs[key] |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
119 |
except KeyError: |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
120 |
continue |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
121 |
return None |
1451 | 122 |
|
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1548
diff
changeset
|
123 |
def etype_get(self, etype, rtype, role, ttype='*'): |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1548
diff
changeset
|
124 |
if role == 'subject': |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1548
diff
changeset
|
125 |
return self.get(etype, rtype, ttype, role) |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1548
diff
changeset
|
126 |
return self.get(ttype, rtype, etype, role) |
1533 | 127 |
|
128 |
||
1451 | 129 |
|
1533 | 130 |
class RelationTagsSet(RelationTags): |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
131 |
"""This class associates a set of tags to each key. |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
132 |
""" |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
133 |
tag_container_cls = set |
1533 | 134 |
|
1739 | 135 |
def tag_relation(self, key, tag): |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
136 |
rtags = self._tagdefs.setdefault(_ensure_str_key(key), |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
137 |
self.tag_container_cls()) |
1148
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
138 |
rtags.add(tag) |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
139 |
return rtags |
1451 | 140 |
|
1739 | 141 |
def get(self, stype, rtype, otype, tagged): |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
142 |
rtags = self.tag_container_cls() |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1548
diff
changeset
|
143 |
for key in self._get_keys(stype, rtype, otype, tagged): |
1148
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
144 |
try: |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
145 |
rtags.update(self._tagdefs[key]) |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
146 |
except KeyError: |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
147 |
continue |
55a8238f8f7c
keep notion of relation tags, tough with simplier implementation and usage
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
148 |
return rtags |
1739 | 149 |
|
150 |
||
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
151 |
class RelationTagsDict(RelationTagsSet): |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
152 |
"""This class associates a set of tags to each key.""" |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
153 |
tag_container_cls = dict |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
154 |
|
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
155 |
def tag_relation(self, key, tag): |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
156 |
key = _ensure_str_key(key) |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
157 |
try: |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
158 |
rtags = self._tagdefs[key] |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
159 |
rtags.update(tag) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
160 |
return rtags |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
161 |
except KeyError: |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
162 |
self._tagdefs[key] = tag |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
163 |
return tag |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
164 |
|
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
165 |
def setdefault(self, key, tagkey, tagvalue): |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
166 |
key = _ensure_str_key(key) |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
167 |
try: |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
168 |
rtags = self._tagdefs[key] |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
169 |
rtags.setdefault(tagkey, tagvalue) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
170 |
return rtags |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
171 |
except KeyError: |
3472
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
172 |
self._tagdefs[key] = {tagkey: tagvalue} |
5345570eefc6
[rtags] make internal key order consistent with api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2689
diff
changeset
|
173 |
return self._tagdefs[key] |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
174 |
|
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
175 |
|
1739 | 176 |
class RelationTagsBool(RelationTags): |
177 |
_allowed_values = frozenset((True, False)) |
|
178 |
||
179 |
||
1740
2292ae32c98f
warn and drop rtags not in schema, this may be intentional; drop possibility to not specify value for bool rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
180 |
set_log_methods(RelationTags, logging.getLogger('cubicweb.rtags')) |