@with_session
def from_cache(session=None, search_params=None, cache_type=None):
 if (not any(search_params.values())):
  raise LookupError(u'No parameters sent for cache lookup')
 else:
  log.debug(u'searching db {0} for the values {1}'.format(cache_type.__tablename__, list(search_params.items())))
  result = session.query(cache_type).filter(or_(((getattr(cache_type, col) == val) for (col, val) in search_params.items() if val))).first()
 return result

@ with_session def from_cache ( session = None , search_params = None , cache_type = None ) : if ( not any ( search_params . values ( ) ) ) : raise LookupError ( u'No parameters sent for cache lookup' ) else : log . debug ( u'searching db {0} for the values {1}' . format ( cache_type . __tablename__ , list ( search_params . items ( ) ) ) ) result = session . query ( cache_type ) . filter ( or_ ( ( ( getattr ( cache_type , col ) == val ) for ( col , val ) in search_params . items ( ) if val ) ) ) . first ( ) return result
returns a result from requested table based on search params .