fix bug in update method
authorTony Mack <tmack@cs.princeton.edu>
Thu, 27 Aug 2009 23:16:20 +0000 (23:16 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Thu, 27 Aug 2009 23:16:20 +0000 (23:16 +0000)
sfa/methods/update.py
sfa/util/genitable.py

index c8458e2..03433f4 100644 (file)
@@ -83,7 +83,7 @@ class update(Method):
                 persons = self.api.plshell.GetPersons(self.api.plauth, [pointer], ['key_ids'])
                 person = persons[0]
                 keys = person['key_ids']
-                keys = GetKeys(person['key_ids'])
+                keys = self.api.plshell.GetKeys(self.api.plauth, person['key_ids'])
                 key_exists = False
                 # Delete all stale keys
                 for key in keys:
@@ -92,7 +92,7 @@ class update(Method):
                     else:
                         key_exists = True
                 if not key_exists:
-                    self.api.plshell.AddPersonKey(pointer, {'key_type': 'ssh', 'key': record['key']})
+                    self.api.plshell.AddPersonKey(self.api.plauth, pointer, {'key_type': 'ssh', 'key': record['key']})
 
                 # find the existing geni record
                 hrn = record['hrn']
@@ -107,9 +107,9 @@ class update(Method):
                 uuid = create_uuid()
                 gid_object = self.api.auth.hierarchy.create_gid(hrn, uuid, pkey)
                 gid = gid_object.save_to_string(save_parents=True)
-                person_record['gid'] = gid
-                person_record.set_gid(gid)
-                table.update(person_record)
+                record['gid'] = gid
+                record.set_gid(gid)
+                table.update(record)
                  
         elif type == "node":
             self.api.plshell.UpdateNode(self.api.plauth, pointer, record)
index c09ac1a..4ad582b 100644 (file)
@@ -84,12 +84,12 @@ class GeniTable:
 
     def update(self, record):
         dont_update = ['date_created', 'last_updated']
-        names = record.get_field_names()
-        names = [name for name in names if name not in dont_update]
+        fields = [field for field in  record.fields.keys() if field not in dont_update]  
+        fieldvals = record.get_field_value_strings(fields)
         pairs = []
-        for name in names:
-           val = record.get_field_value_string(name)
-           pairs.append(name + " = " + val)
+        for field in fields:
+            val = record.get_field_value_string(field)
+            pairs.append(field + " = " + val)
         update = ", ".join(pairs)
 
         query_str = "UPDATE " + self.tablename+ " SET " + update + " WHERE key = '" + record.get_key() + "'"