|
@@ -144,6 +144,9 @@ class _LeObject(object):
|
144
|
144
|
# @throw LeObjectError if the link is not valid
|
145
|
145
|
# @throw AttributeError if an non existing relation attribute is given as argument
|
146
|
146
|
# @throw ValueError if the relation attrivute value check fails
|
|
147
|
+ #
|
|
148
|
+ # @todo Code factorisation on relation check
|
|
149
|
+ # @todo unit tests
|
147
|
150
|
@classmethod
|
148
|
151
|
def link_together(cls, lesup, lesub, **rel_attr):
|
149
|
152
|
if lesub.__class__ not in lesup._linked_types.keys():
|
|
@@ -162,6 +165,9 @@ class _LeObject(object):
|
162
|
165
|
# @param leo_is_superior bool : if True leo is the superior in the relation
|
163
|
166
|
# @return A dict with LeType child class instance as key and dict {rel_attr_name:rel_attr_value, ...}
|
164
|
167
|
# @throw LeObjectError if the relation is not possible
|
|
168
|
+ #
|
|
169
|
+ # @todo Code factorisation on relation check
|
|
170
|
+ # @todo unit tests
|
165
|
171
|
@classmethod
|
166
|
172
|
def linked_together(cls, leo, letype, leo_is_superior = True):
|
167
|
173
|
valid_link = letype in leo._linked_types.keys() if leo_is_superior else leo.__class__ in letype._linked_types.keys()
|
|
@@ -174,6 +180,21 @@ class _LeObject(object):
|
174
|
180
|
|
175
|
181
|
return cls._datasource.get_related(leo, letype, leo_is_superior)
|
176
|
182
|
|
|
183
|
+ ## @brief Remove a link (and attributes) between two LeObject
|
|
184
|
+ # @param lesup LeType : LeType child instance
|
|
185
|
+ # @param lesub LeType : LeType child instance
|
|
186
|
+ # @return True if a link has been deleted
|
|
187
|
+ # @throw LeObjectError if the relation between the two LeObject is not possible
|
|
188
|
+ #
|
|
189
|
+ # @todo Code factorisation on relation check
|
|
190
|
+ # @todo unit tests
|
|
191
|
+ @classmethod
|
|
192
|
+ def link_remove(cls, lesup, lesub):
|
|
193
|
+ if lesub.__class__ not in lesup._linked_types.keys():
|
|
194
|
+ raise LeObjectError("Relation errorr : %s cannot be linked with %s"%(lesup.__class__.__name__, lesub.__class__.__name__))
|
|
195
|
+
|
|
196
|
+ return cls._datasource.del_related(lesup, lesub)
|
|
197
|
+
|
177
|
198
|
## @brief Prepare a field_list
|
178
|
199
|
# @param field_list list : List of string representing fields
|
179
|
200
|
# @param letype LeType : LeType child class
|