changeset 126:ffc3c706b0fb

Don't return anything when removing items, and raise exception when an item is not found. Return items for get_items() in unicode string.
author Ralph Meijer <ralphm@ik.nu>
date Sun, 24 Apr 2005 17:19:27 +0000
parents 0d7b95fb2549
children d3689da18ed2
files idavoll/memory_storage.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/idavoll/memory_storage.py	Tue Apr 12 14:51:59 2005 +0000
+++ b/idavoll/memory_storage.py	Sun Apr 24 17:19:27 2005 +0000
@@ -161,22 +161,22 @@
         deleted = []
 
         for item_id in item_ids:
-            try:
-                item = self._items[item_id]
-                self._itemlist.remove(item)
-                del self._items[item_id]
-                deleted.append(item_id)
-            except KeyError:
-                pass
+            if not self._items.has_key(item_id):
+                return defer.fail(storage.ItemNotFound())
+
+        for item_id in item_ids:
+            item = self._items[item_id]
+            self._itemlist.remove(item)
+            del self._items[item_id]
         
-        return defer.succeed(deleted)
+        return defer.succeed(None)
 
     def get_items(self, max_items=None):
         if max_items:
             list = self._itemlist[-max_items:]
         else:
             list = self._itemlist
-        return defer.succeed([item[0] for item in list])
+        return defer.succeed([unicode(item[0], 'utf-8') for item in list])
     
     def get_items_by_id(self, item_ids):
         items = []
@@ -186,7 +186,7 @@
             except KeyError:
                 pass
             else:
-                items.append(item[0])
+                items.append(unicode(item[0], 'utf-8'))
         return defer.succeed(items)
 
     def purge(self):