- if a node has no nodenetworks, make the first one added primary
authorTony Mack <tmack@cs.princeton.edu>
Thu, 2 Nov 2006 14:57:25 +0000 (14:57 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Thu, 2 Nov 2006 14:57:25 +0000 (14:57 +0000)
PLC/Methods/AddNodeNetwork.py

index a37ce40..34498a6 100644 (file)
@@ -64,6 +64,9 @@ class AddNodeNetwork(Method):
         # Add node network
        nodenetwork = NodeNetwork(self.api, nodenetwork_fields)
         nodenetwork['node_id'] = node['node_id']
+       # if this is the first node network, make it primary
+       if not node['nodenetwork_ids']:
+               nodenetwork['is_primary'] = True
         nodenetwork.sync()
 
        self.object_ids = [node['node_id'], nodenetwork['nodenetwork_id']]