def _image_get(context, image_id, session=None, force_show_deleted=False):
 session = (session or get_session())
 try:
  query = session.query(models.Image).options(sa_orm.joinedload(models.Image.properties)).options(sa_orm.joinedload(models.Image.locations)).filter_by(id=image_id)
  if ((not force_show_deleted) and (not _can_show_deleted(context))):
   query = query.filter_by(deleted=False)
  image = query.one()
 except sa_orm.exc.NoResultFound:
  raise exception.NotFound(('No image found with ID %s' % image_id))
 if (not is_image_visible(context, image)):
  raise exception.Forbidden('Image not visible to you')
 return image

def _image_get ( context , image_id , session = None , force_show_deleted = False ) : session = ( session or get_session ( ) ) try : query = session . query ( models . Image ) . options ( sa_orm . joinedload ( models . Image . properties ) ) . options ( sa_orm . joinedload ( models . Image . locations ) ) . filter_by ( id = image_id ) if ( ( not force_show_deleted ) and ( not _can_show_deleted ( context ) ) ) : query = query . filter_by ( deleted = False ) image = query . one ( ) except sa_orm . exc . NoResultFound : raise exception . NotFound ( ( 'No image found with ID %s' % image_id ) ) if ( not is_image_visible ( context , image ) ) : raise exception . Forbidden ( 'Image not visible to you' ) return image
get an image or raise if it does not exist .