From 7b3cd8c380eef8a1078ab4566f669613af2c2992 Mon Sep 17 00:00:00 2001
From: Mark Huang <mlhuang@cs.princeton.edu>
Date: Wed, 11 Oct 2006 15:42:29 +0000
Subject: [PATCH] - check for both key_id_list = None and key_id_list = [],
 both of which   Keys interprets to mean "all keys"

---
 PLC/Methods/GetKeys.py | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/PLC/Methods/GetKeys.py b/PLC/Methods/GetKeys.py
index baabca1f..00a0db24 100644
--- a/PLC/Methods/GetKeys.py
+++ b/PLC/Methods/GetKeys.py
@@ -6,11 +6,11 @@ from PLC.Auth import PasswordAuth
 
 class GetKeys(Method):
     """
-    Get an array of structs containing the keys for the specified
-    key_ids. If key_id_list is not specified, all keys
-    will be queried.
+    Return an array of structs containing details about keys. If
+    key_id_list is specified, only the specified keys will be queried.
 
-    Admin may get all keys. Non-admins can only get their own keys
+    Admin may query all keys. Non-admins may only query their own
+    keys.
     """
 
     roles = ['admin', 'pi', 'user', 'tech']
@@ -23,20 +23,14 @@ class GetKeys(Method):
     returns = [Key.fields]
 
     def call(self, auth, key_id_list = None):
-        	
-	#if we are not admin, make sure to only return our own keys       
+	# If we are not admin, make sure to only return our own keys       
         if 'admin' not in self.caller['roles']:
-		if key_id_list is None:
-			key_id_list =  self.caller['key_ids']
-		else:
-			valid_keys = lambda x: x in self.caller['key_ids']
-			key_id_list = filter(valid_keys, key_id_list)
+            if not key_id_list:
+                key_id_list = self.caller['key_ids']
+            else:
+                valid_keys = lambda x: x in self.caller['key_ids']
+                key_id_list = filter(valid_keys, key_id_list)
 		
 	keys = Keys(self.api, key_id_list).values()
 	
-	# Filter out undesired or None fields (XML-RPC cannot marshal
-        # None) and turn each key into a real dict.
-	valid_return_fields_only = lambda (key, value): value is not None
-        keys = [dict(filter(valid_return_fields_only, key.items())) \
-                      for key in keys]		
         return keys
-- 
2.47.0