required to mark peer_id of key object
[plcapi.git] / PLC / Methods / BindObjectToPeer.py
index a4cfd58..70f24c3 100644 (file)
@@ -1,4 +1,5 @@
-# $Id: ResolveSlices.py 12217 2009-02-24 17:28:54Z thierry $
+# $Id$
+# $URL$
 
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
@@ -8,6 +9,7 @@ from PLC.Persons import Persons
 from PLC.Sites import Sites
 from PLC.Nodes import Nodes
 from PLC.Slices import Slices
+from PLC.Keys import Keys
 from PLC.Peers import Peers
 from PLC.Faults import *
  
@@ -61,6 +63,11 @@ class BindObjectToPeer(Method):
 
         peer=peers[0]
         object = self.locate_object (object_type, object_id)
+        
+        # There is no need to continue if the object is already bound to this peer  
+        if object['peer_id'] in [peer['peer_id']]:
+            return 1
+        
         adder_name = 'add_'+object_type
         add_function = getattr(type(peer),adder_name)
         add_function(peer,object,remote_object_id)