comparison idavoll/memory_storage.py @ 142:812300cdbc22

Changed behaviour of retraction of items so that only the actually deleted item ids are returned, and no exception is raised for items that didn't actually exists.
author Ralph Meijer <ralphm@ik.nu>
date Tue, 12 Jul 2005 09:23:00 +0000
parents 8f6956b9a688
children f393bccec4bc
comparison
equal deleted inserted replaced
141:d2c18d88f618 142:812300cdbc22
162 162
163 def remove_items(self, item_ids): 163 def remove_items(self, item_ids):
164 deleted = [] 164 deleted = []
165 165
166 for item_id in item_ids: 166 for item_id in item_ids:
167 if not self._items.has_key(item_id): 167 try:
168 return defer.fail(storage.ItemNotFound()) 168 item = self._items[item_id]
169 169 except KeyError:
170 for item_id in item_ids: 170 pass
171 item = self._items[item_id] 171 else:
172 self._itemlist.remove(item) 172 self._itemlist.remove(item)
173 del self._items[item_id] 173 del self._items[item_id]
174 deleted.append(item_id)
174 175
175 return defer.succeed(None) 176 return defer.succeed(deleted)
176 177
177 def get_items(self, max_items=None): 178 def get_items(self, max_items=None):
178 if max_items: 179 if max_items:
179 list = self._itemlist[-max_items:] 180 list = self._itemlist[-max_items:]
180 else: 181 else: