]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
HistoryArrayList checks internal list as a list or dict to clear it
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 10 Mar 2006 04:22:59 +0000 (04:22 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 10 Mar 2006 04:22:59 +0000 (04:22 +0000)
lib/sqlalchemy/util.py

index d60166a0c1eba1975bacaa8c603c9509dbe0dcca..2b522d5711ea8d6bec085c5cf7f412561c0bdb7b 100644 (file)
@@ -365,14 +365,19 @@ class HistoryArraySet(UserList.UserList):
         for key, status in self.records.iteritems():
             if status is False or status is None:
                 list.append(key)
-        self.data[:] = []
+        self._clear_data()
         self.records = {}
         for l in list:
             self.append_nohistory(l)
     def clear(self):
         """clears the list and removes all history."""
-        self.data[:] = []
+        self._clear_data()
         self.records = {}
+    def _clear_data(self):
+        if isinstance(self.data, dict):
+            self.data.clear()
+        else:
+            self.data[:] = []
     def added_items(self):
         """returns a list of items that have been added since the last "committed" state."""
         return [key for key in self.data if self.records[key] is True]