Fix sending ITEMs for empty tags
authorJack Miller <jack@codezen.org>
Sat, 13 Sep 2014 00:45:35 +0000 (19:45 -0500)
committerJack Miller <jack@codezen.org>
Sat, 13 Sep 2014 00:45:35 +0000 (19:45 -0500)
canto_next/canto_backend.py

index fa0a668..f418f5a 100644 (file)
@@ -395,17 +395,20 @@ class CantoBackend(PluginHandler, CantoServer):
 
             attr_list = []
 
-            while len(items):
-                chunk = items[:100]
-                items = items[100:]
+            if len(items) == 0:
+                self.write(socket, "ITEMS", { tag : [] })
+            else:
+                while len(items):
+                    chunk = items[:100]
+                    items = items[100:]
 
-                attr_req = {}
-                if socket in self.autoattr:
-                    for id in chunk:
-                        attr_req[id] = self.autoattr[socket][:]
+                    attr_req = {}
+                    if socket in self.autoattr:
+                        for id in chunk:
+                            attr_req[id] = self.autoattr[socket][:]
 
-                self.write(socket, "ITEMS", { tag : chunk })
-                attr_list.append(attr_req)
+                    self.write(socket, "ITEMS", { tag : chunk })
+                    attr_list.append(attr_req)
 
             self.write(socket, "ITEMSDONE", {})