- Change .py files to use 4-space indents and no hard tab characters.
[plcapi.git] / PLC / Methods / GetKeys.py
index b9cf110..0451f45 100644 (file)
@@ -1,7 +1,10 @@
+# $Id$
+# $URL$
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.Filter import Filter
+from PLC.Persons import Person, Persons
 from PLC.Keys import Key, Keys
 from PLC.Auth import Auth
 
@@ -17,25 +20,24 @@ class GetKeys(Method):
     keys.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
+    roles = ['admin', 'pi', 'user', 'tech', 'node']
 
     accepts = [
         Auth(),
         Mixed([Mixed(Key.fields['key_id'])],
               Filter(Key.fields)),
-        Parameter([str], "List of fields to return", nullok = True)        
+        Parameter([str], "List of fields to return", nullok = True)
         ]
 
     returns = [Key.fields]
 
-    event_type = 'Get'
-    object_type = 'Key'
 
     def call(self, auth, key_filter = None, return_fields = None):
-       keys = Keys(self.api, key_filter, return_fields)
+        keys = Keys(self.api, key_filter, return_fields)
 
-       # If we are not admin, make sure to only return our own keys       
-        if 'admin' not in self.caller['roles']:
+        # If we are not admin, make sure to only return our own keys
+        if isinstance(self.caller, Person) and \
+           'admin' not in self.caller['roles']:
             keys = filter(lambda key: key['key_id'] in self.caller['key_ids'], keys)
 
         return keys