@db_api.retry_if_session_inactive()
def _ensure_external_network_default_value_callback(resource, event, trigger, context, request, network):
 is_default = request.get(IS_DEFAULT, False)
 if ((event in (events.BEFORE_CREATE, events.BEFORE_UPDATE)) and is_default):
  obj = context.session.query(ext_net_models.ExternalNetwork).filter_by(is_default=True).first()
  if (obj and (network['id'] != obj.network_id)):
   raise exceptions.DefaultExternalNetworkExists(net_id=obj.network_id)
 obj = context.session.query(ext_net_models.ExternalNetwork).filter_by(network_id=network['id'])
 obj.update({IS_DEFAULT: is_default})

@ db_api . retry_if_session_inactive ( ) def _ensure_external_network_default_value_callback ( resource , event , trigger , context , request , network ) : is_default = request . get ( IS_DEFAULT , False ) if ( ( event in ( events . BEFORE_CREATE , events . BEFORE_UPDATE ) ) and is_default ) : obj = context . session . query ( ext_net_models . ExternalNetwork ) . filter_by ( is_default = True ) . first ( ) if ( obj and ( network [ 'id' ] != obj . network_id ) ) : raise exceptions . DefaultExternalNetworkExists ( net_id = obj . network_id ) obj = context . session . query ( ext_net_models . ExternalNetwork ) . filter_by ( network_id = network [ 'id' ] ) obj . update ( { IS_DEFAULT : is_default } )
ensure the is_default db field matches the create/update request .