#NEWLINE# def find_res_by_name( self , name , restype = None , id_only = False , filter = None ) : #NEWLINE# #INDENT# log . debug ( 'find_res_by_name(name=%s, restype=%s)' , name , restype ) #NEWLINE# if ( type ( id_only ) is not bool ) : #NEWLINE# #INDENT# raise BadRequest ( ( 'id_only must be type bool, not %s' % type ( id_only ) ) ) #NEWLINE# #UNINDENT# filter = ( filter if ( filter is not None ) else { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# qual_ds_name = self . _get_datastore_name ( ) #NEWLINE# if id_only : #NEWLINE# #INDENT# query = ( 'SELECT id, name, type_ FROM ' + qual_ds_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# query = ( 'SELECT id, name, type_, doc FROM ' + qual_ds_name ) #NEWLINE# #UNINDENT# query_clause = " WHERE lcstate<>'DELETED' " #NEWLINE# query_args = dict ( name = name , type_ = restype ) #NEWLINE# query_clause += 'AND name=%(name)s' #NEWLINE# if restype : #NEWLINE# #INDENT# query_clause += ' AND type_=%(type_)s' #NEWLINE# #UNINDENT# query_clause = self . _add_access_filter ( filter , qual_ds_name , query_clause , query_args ) #NEWLINE# extra_clause = filter . get ( 'extra_clause' , '' ) #NEWLINE# with self . pool . cursor ( ** self . cursor_args ) as cur : #NEWLINE# #INDENT# cur . execute ( ( ( query + query_clause ) + extra_clause ) , query_args ) #NEWLINE# rows = cur . fetchall ( ) #NEWLINE# #UNINDENT# res_assocs = [ dict ( id = self . _prep_id ( row [ 0 ] ) , name = row [ 1 ] , type = row [ 2 ] ) for row in rows ] #NEWLINE# log . debug ( 'find_res_by_name() found %s objects' , len ( res_assocs ) ) #NEWLINE# return self . _prepare_find_return ( rows , res_assocs , id_only = id_only )