From: Mike Bayer Date: Wed, 7 Sep 2005 04:05:13 +0000 (+0000) Subject: moved major awareness of lists, lazyloading, etc. all into the objectstore X-Git-Tag: rel_0_1_0~787 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=262b90579bc37b39e91a3798b944a0af496d0bd1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git moved major awareness of lists, lazyloading, etc. all into the objectstore --- diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index d575b22890..ead1821432 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -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]