def _gcm_handle_canonical_id(canonical_id, current_id, cloud_type):
 if GCMDevice.objects.filter(registration_id=canonical_id, cloud_message_type=cloud_type, active=True).exists():
  GCMDevice.objects.filter(registration_id=current_id, cloud_message_type=cloud_type).update(active=False)
 else:
  GCMDevice.objects.filter(registration_id=current_id, cloud_message_type=cloud_type).update(registration_id=canonical_id)

def _gcm_handle_canonical_id ( canonical_id , current_id , cloud_type ) : if GCMDevice . objects . filter ( registration_id = canonical_id , cloud_message_type = cloud_type , active = True ) . exists ( ) : GCMDevice . objects . filter ( registration_id = current_id , cloud_message_type = cloud_type ) . update ( active = False ) else : GCMDevice . objects . filter ( registration_id = current_id , cloud_message_type = cloud_type ) . update ( registration_id = canonical_id )
handle situation when gcm server response contains canonical id .