]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
moved major awareness of lists, lazyloading, etc. all into the objectstore
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Sep 2005 04:05:13 +0000 (04:05 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Sep 2005 04:05:13 +0000 (04:05 +0000)
lib/sqlalchemy/util.py

index d575b22890b1af75b2896bd8d01ae8618d200e73..ead1821432b7652ecda564c9dc2506cd37ad63a2 100644 (file)
@@ -122,14 +122,30 @@ class HashSet(object):
         return self.map[key]
         
 class HistoryArraySet(UserList.UserList):
-    def __init__(self, items = None):
+    def __init__(self, items = None, data = None):
         UserList.UserList.__init__(self, items)
         # stores the array's items as keys, and a value of True, False or None indicating
         # added, deleted, or unchanged for that item
+        if data is not None:
+            self.data = data
         self.records = {}
-        if items is not None:
-            for i in items:
-                self.records[i] = True
+        for i in self.data:
+            self.records[i] = True
+
+    def set_data(self, data):
+        # first mark everything current as "deleted"
+        for i in self.data:
+            self.records[i] = False
+            
+        # switch array
+        self.data = data
+
+        # TODO: fix this up, remove items from array while iterating
+        for i in range(0, len(self.data)):
+            if not _setrecord(self, self.data[i]):
+               del self.data[i]
+               i -= 1
+
     def _setrecord(self, item):
         try:
             val = self.records[item]