Browse Source

Add a rel2type_name to LeType methods about linked stuff

Yann Weber 9 years ago
parent
commit
81d194974b
1 changed files with 8 additions and 5 deletions
  1. 8
    5
      leobject/letype.py

+ 8
- 5
leobject/letype.py View File

@@ -102,20 +102,22 @@ class LeType(object):
102 102
         return self._datasource(leo, self, nature)
103 103
 
104 104
     ## @brief Get the linked objects lodel_id
105
+    # @param rel2type_name str : the name of the relation
105 106
     # @return an array of lodel_id linked with this object
106 107
     # @todo unit tests
107
-    def linked(self):
108
+    def linked(self, rel2type_name):
108 109
         return [ rel['id_sub'] for rel in self._datasource.get_relations(self.lodel_id) ]
109 110
 
110 111
     ## @brief Link this object with a LeObject
111 112
     # @note rel2type
112 113
     # @param leo LeObject : The object to be linked with
114
+    # @param rel2type_name : The name of the rel2type field (the name of the relation)
113 115
     # @param **rel_attr : keywords arguments for relations attributes
114 116
     # @return True if success False allready done
115 117
     # @throw A Leo exception if the link is not allowed
116 118
     # @todo unit tests
117 119
     # @todo find a value for depth and rank....
118
-    def link_to(self, leo, **rel_attr):
120
+    def link_to(self, leo, rel2type_name, **rel_attr):
119 121
         if leo.__class__ not in self._linked_types.keys():
120 122
             raise leobject.leobject.LeObjectError("Constraint error : %s cannot be linked with %s"%(self.__class__.__name__, leo.__class__.__name__))
121 123
 
@@ -125,13 +127,14 @@ class LeType(object):
125 127
             if not self._linked_types[leo.__class__][1].check(rel_attr[attr_name]):
126 128
                 raise ValueError("Wrong value '%s' for attribute %s"%(rel_attr[attr_name], attr_name))
127 129
 
128
-        return self._datasource.add_relation(self, leo, nature=None, depth=None, rank=None, **rel_attr)
130
+        return self._datasource.add_relation(self, leo, nature=None, depth=None, rank=None, **rel_attr)#Broken ! need to give the rel2type_name
129 131
 
130 132
     ## @brief Remove a link bewteen this object and another
131 133
     # @param leo LeObject : A LeObject instance linked with self
134
+    # @param rel2type_name : the name of the relation
132 135
     # @todo unit tests
133
-    def unlink(self, leo):
134
-        return self._datasource.del_relation(self, leo)
136
+    def unlink(self, leo, rel2type_name):
137
+        return self._datasource.del_relation(self, leo) #Broken ! need to give the rel2type_name
135 138
         
136 139
     ## @brief Delete a LeType from the datasource
137 140
     # @param filters list : list of filters (see @ref leobject_filters)

Loading…
Cancel
Save