bug-fix
[sfa.git] / sfa / methods / update.py
index ff40f58..2e97a5b 100644 (file)
@@ -10,6 +10,7 @@ from sfa.util.genitable import GeniTable
 from sfa.trust.certificate import Keypair, convert_public_key
 from sfa.trust.gid import *
 from sfa.util.debug import log
+from sfa.trust.credential import Credential
 
 class update(Method):
     """
@@ -32,15 +33,20 @@ class update(Method):
 
     returns = Parameter(int, "1 if successful")
     
-    def call(self, cred, record_dict):
+    def call(self, cred, record_dict, caller_cred=None):
         self.api.auth.check(cred, "update")
+       if caller_cred==None:
+          caller_cred=cred
+
+       #log the call
+       self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), None, self.name))
         new_record = GeniRecord(dict = record_dict)
         type = new_record['type']
         hrn = new_record['hrn']
         self.api.auth.verify_object_permission(hrn)
         table = GeniTable()
         # make sure the record exists
-        records = table.find({'type': type, 'hrn': hrn})
+        records = table.findObjects({'type': type, 'hrn': hrn})
         if not records:
             raise RecordNotFound(hrn)
         record = records[0]
@@ -114,6 +120,6 @@ class update(Method):
             raise UnknownGeniType(type)
 
         # update membership for researchers, pis, owners, operators
-        self.api.update_membership(record, record)
+        self.api.update_membership(record, new_record)
 
         return 1