mirror of
https://github.com/yweber/lodel2.git
synced 2025-11-30 08:36:53 +01:00
Removed unused & obsolete code in leapi/letype.py
This commit is contained in:
parent
94b843e321
commit
b34ce35e85
1 changed files with 0 additions and 89 deletions
|
|
@ -107,92 +107,3 @@ class _LeType(_LeClass):
|
||||||
datas['superior'] = self
|
datas['superior'] = self
|
||||||
datas['subordinate'] = leo_tolink
|
datas['subordinate'] = leo_tolink
|
||||||
return r2tcls.insert(datas, class_name)
|
return r2tcls.insert(datas, class_name)
|
||||||
|
|
||||||
## @brief Get the linked objects lodel_id
|
|
||||||
# @param letype LeType : Filter the result with LeType child class (not instance)
|
|
||||||
# @return a dict with LeType instance as key and dict{attr_name:attr_val...} as value
|
|
||||||
# @todo unit tests
|
|
||||||
def ___linked(self, letype):
|
|
||||||
if leapi.letype.LeType not in letype.__bases__:
|
|
||||||
raise ValueError("letype has to be a child class of LeType (not an instance) but %s found"%type(letype))
|
|
||||||
|
|
||||||
if letype in self._linked_types.keys():
|
|
||||||
get_sub = True
|
|
||||||
elif self.__class__ in letype._linked_types.keys():
|
|
||||||
get_sub = False
|
|
||||||
else:
|
|
||||||
raise ValueError("The two LeType classes %s and %s are not linked with a rel2type field"%(self.__class__.__name__, letype.__name__))
|
|
||||||
|
|
||||||
return self._datasource.get_related(self, letype, get_sub)
|
|
||||||
|
|
||||||
## @brief Link this object with a LeObject as subordinate
|
|
||||||
# @note shortcut for @ref leapi.leapi._LeObject.link_together()
|
|
||||||
# @param lesub LeObject : The object to be linked with as subordinate
|
|
||||||
# @param **rel_attr : keywords arguments for relations attributes
|
|
||||||
# @return The relation_id if success else return False
|
|
||||||
# @throw LeObjectError if the link is not valid
|
|
||||||
# @throw LeObkectError if the link already exists
|
|
||||||
# @throw AttributeError if an non existing relation attribute is given as argument
|
|
||||||
# @throw ValueError if the relation attrivute value check fails
|
|
||||||
# @see leapi.lefactory.LeFactory.link_together()
|
|
||||||
def ___link(self, leo, **rel_attr):
|
|
||||||
return leapi.lefactory.LeFactory.leobj_from_name('LeObject').link_together(self, leo, **rel_attr)
|
|
||||||
|
|
||||||
## @brief Returns linked subordinates in a rel2type given a wanted LeType child class
|
|
||||||
# @param letype LeType(class) : The wanted LeType of result
|
|
||||||
# @return A dict with LeType child class instance as key and dict {'id_relation':id, rel_attr_name:rel_attr_value, ...}
|
|
||||||
# @throw LeObjectError if the relation is not possible
|
|
||||||
# @see leapi.lefactory.LeFactory.linked_together()
|
|
||||||
def ___linked_subordinates(self, letype):
|
|
||||||
return leapi.lefactory.LeFactory.leobj_from_name('LeObject').linked_together(self, letype, True)
|
|
||||||
|
|
||||||
## @brief Remove a link with a subordinate
|
|
||||||
# @param leo LeType : LeType child instance
|
|
||||||
# @return True if a link has been deleted
|
|
||||||
# @throw LeObjectError if the relation do not concern the current LeType
|
|
||||||
def ___unlink_subordinate(self, id_relation):
|
|
||||||
return leapi.lefactory.LeFactory.leobj_from_name('LeObject').linked_together(self, leo)
|
|
||||||
|
|
||||||
## @brief Remove a link bewteen this object and another
|
|
||||||
# @param leo LeType : LeType child class instance
|
|
||||||
# @todo unit tests
|
|
||||||
def ___unlink(self, leo):
|
|
||||||
if leo.__class__ in self._linked_types.keys():
|
|
||||||
sup = self
|
|
||||||
sub = leo
|
|
||||||
elif self.__class__ in leo._linked_types.keys():
|
|
||||||
sup = leo
|
|
||||||
sub = self
|
|
||||||
|
|
||||||
return self._datasource.del_related(sup, sub)
|
|
||||||
|
|
||||||
## @brief Add a superior
|
|
||||||
# @param lesup LeType | LeRoot : LeType child class instance that will be the superior
|
|
||||||
# @param nature str : The nature of the relation @ref EditorialModel.classtypes
|
|
||||||
# @param rank str|int : The relation rank. Can be 'last', 'first' or an integer
|
|
||||||
# @param replace_if_exists bool : if True delete the old superior and set the new one. If False and there is a superior raise an LeObjectQueryError
|
|
||||||
# @return The relation ID or False if fails
|
|
||||||
def ___superior_add(self, leo, nature, rank = 'last', replace_if_exists = False):
|
|
||||||
return leapi.lefactory.LeFactory.leobj_from_name('LeObject').hierarchy_add(leo, self, nature, rank, replace_if_exists)
|
|
||||||
|
|
||||||
## @brief Delete a superior given a relation's natue
|
|
||||||
# @param leo LeType | LeRoot : The superior to delete
|
|
||||||
# @param nature str : The nature of the relation @ref EditorialModel.classtypes
|
|
||||||
# @return True if deletion is a success
|
|
||||||
def ___superior_del(self, leo, nature):
|
|
||||||
return leapi.lefactory.leobj_from_name('LeObject').hierarchy_del(leo, self, nature)
|
|
||||||
|
|
||||||
## @brief Fetch superiors by depth
|
|
||||||
# @return A list of LeObject ordered by depth (the first is the one with the bigger depth)
|
|
||||||
def ___superiors(self):
|
|
||||||
return leapi.lefactory.leobj_from_name('LeObject').hierarchy_get(self,nature, leo_is_sup = False)
|
|
||||||
|
|
||||||
## @brief Fetch subordinates ordered by rank
|
|
||||||
# @return A list of LeObject ordered by rank
|
|
||||||
def ___subordinates(self):
|
|
||||||
return leapi.lefactory.leobj_from_name('LeObject').hierarchy_get(self,nature, leo_is_sup = True)
|
|
||||||
|
|
||||||
## @brief Update a LeType in db
|
|
||||||
def ___db_update(self):
|
|
||||||
return self.update(filters=[('lodel_id', '=', repr(self.lodel_id))], datas = self.datas)
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue