revert change in append of Multi object for sqlite3 storage
authorEmmanuel Garette <egarette@cadoles.com>
Sun, 25 Aug 2013 18:51:29 +0000 (20:51 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Sun, 25 Aug 2013 18:51:29 +0000 (20:51 +0200)
tiramisu/value.py

index fb62698..b5092d8 100644 (file)
@@ -20,7 +20,7 @@
 from time import time
 from copy import copy
 from tiramisu.error import ConfigError, SlaveError
-from tiramisu.setting import owners, multitypes, expires_time, storage_type
+from tiramisu.setting import owners, multitypes, expires_time
 from tiramisu.autolib import carry_out_calculation
 from tiramisu.i18n import _
 from tiramisu.option import SymLinkOption
@@ -42,7 +42,7 @@ class Values(object):
         """
         self.context = context
         # the storage type is dictionary or sqlite3
-        import_lib = 'tiramisu.storage.{0}.value'.format(storage_type)
+        import_lib = 'tiramisu.storage.{0}.value'.format(storage.storage)
         self._p_ = __import__(import_lib, globals(), locals(), ['Values'],
                               -1).Values(storage)
 
@@ -408,9 +408,16 @@ class Multi(list):
                         dvalue = values._getcallback_value(slave, index=index)
                     else:
                         dvalue = slave.impl_getdefault_multi()
-                    values.getitem(slave, path,
-                                   validate_properties=False).append(
-                                       dvalue, force=True)
+                    old_value = values.getitem(slave, path,
+                                               validate_properties=False)
+                    if len(old_value) < self.__len__():
+                        values.getitem(slave, path,
+                                       validate_properties=False).append(
+                                           dvalue, force=True)
+                    else:
+                        values.getitem(slave, path,
+                                       validate_properties=False)[
+                                           index] = dvalue
 
     def sort(self, cmp=None, key=None, reverse=False):
         if self.opt.impl_get_multitype() in [multitypes.slave,