@logic.validate(logic.schema.default_autocomplete_schema)
def format_autocomplete(context, data_dict):
 model = context['model']
 session = context['session']
 _check_access('format_autocomplete', context, data_dict)
 q = data_dict['q']
 limit = data_dict.get('limit', 5)
 like_q = ((u'%' + q) + u'%')
 query = session.query(model.Resource.format, _func.count(model.Resource.format).label('total')).filter(_and_((model.Resource.state == 'active'))).filter(model.Resource.format.ilike(like_q)).group_by(model.Resource.format).order_by('total DESC').limit(limit)
 return [resource.format.lower() for resource in query]

@ logic . validate ( logic . schema . default_autocomplete_schema ) def format_autocomplete ( context , data_dict ) : model = context [ 'model' ] session = context [ 'session' ] _check_access ( 'format_autocomplete' , context , data_dict ) q = data_dict [ 'q' ] limit = data_dict . get ( 'limit' , 5 ) like_q = ( ( u'%' + q ) + u'%' ) query = session . query ( model . Resource . format , _func . count ( model . Resource . format ) . label ( 'total' ) ) . filter ( _and_ ( ( model . Resource . state == 'active' ) ) ) . filter ( model . Resource . format . ilike ( like_q ) ) . group_by ( model . Resource . format ) . order_by ( 'total DESC' ) . limit ( limit ) return [ resource . format . lower ( ) for resource in query ]
return a list of resource formats whose names contain a string .