def get_port(context, port_id):
 with context.session.begin(subtransactions=True):
  try:
   record = context.session.query(models_v2.Port).enable_eagerloads(False).filter(models_v2.Port.id.startswith(port_id)).one()
   return record
  except exc.NoResultFound:
   return
  except exc.MultipleResultsFound:
   LOG.error(_LE('Multiple ports have port_id starting with %s'), port_id)
   return

def get_port ( context , port_id ) : with context . session . begin ( subtransactions = True ) : try : record = context . session . query ( models_v2 . Port ) . enable_eagerloads ( False ) . filter ( models_v2 . Port . id . startswith ( port_id ) ) . one ( ) return record except exc . NoResultFound : return except exc . MultipleResultsFound : LOG . error ( _LE ( 'Multiple ports have port_id starting with %s' ) , port_id ) return
get port record for update within transaction .