continuation of making request_hash optional
[sfa.git] / sfa / methods / register_peer_object.py
index d54f4bb..359e1bc 100644 (file)
@@ -31,12 +31,15 @@ class register_peer_object(Method):
     
     accepts = [
         Parameter(str, "Credential string"),
-        Parameter(dict, "Record dictionary containing record fields")
+        Parameter(dict, "Record dictionary containing record fields"),
+        Mixed(Parameter(str, "Request hash"),
+              Parameter(None, "Request hash not specified"))
         ]
 
     returns = Parameter(int, "1 if successful")
     
-    def call(self, cred, record_dict, caller_cred=None):
+    def call(self, cred, record_dict, request_hash=None, caller_cred=None):
+        self.api.auth.authenticateCred(cred, [cred], request_hash)
         self.api.auth.check(cred, "register")
         if caller_cred==None:
                caller_cred=cred
@@ -61,6 +64,7 @@ class register_peer_object(Method):
         if existing_records:
             for existing_record in existing_records:
                 if existing_record['pointer'] != record['pointer']:
+                    record['record_id'] = existing_record['record_id']
                     table.update(record)
             return 1
         record_id = table.insert(record)