Browse Source

EmModel : create_component() can take an optional uid

ArnAud 9 years ago
parent
commit
ea302bb469
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      EditorialModel/model.py

+ 2
- 2
EditorialModel/model.py View File

129
     # @param datas dict : the options needed by the component creation
129
     # @param datas dict : the options needed by the component creation
130
     # @throw ValueError if datas['rank'] is not valid (too big or too small, not an integer nor 'last' or 'first' )
130
     # @throw ValueError if datas['rank'] is not valid (too big or too small, not an integer nor 'last' or 'first' )
131
     # @todo Handle a raise from the migration handler
131
     # @todo Handle a raise from the migration handler
132
-    def create_component(self, component_type, datas):
132
+    def create_component(self, component_type, datas, uid=None):
133
 
133
 
134
         em_obj = self.emclass_from_name(component_type)
134
         em_obj = self.emclass_from_name(component_type)
135
 
135
 
138
             rank = datas['rank']
138
             rank = datas['rank']
139
             del datas['rank']
139
             del datas['rank']
140
 
140
 
141
-        datas['uid'] = self.new_uid()
141
+        datas['uid'] = uid if uid else self.new_uid()
142
         em_component = em_obj(self, **datas)
142
         em_component = em_obj(self, **datas)
143
 
143
 
144
         em_component.rank = em_component.get_max_rank() + 1 #Inserting last by default
144
         em_component.rank = em_component.get_max_rank() + 1 #Inserting last by default

Loading…
Cancel
Save