def retrieve_collection(collection, query_arguments=None):
    """Return the resources in *collection*, possibly filtered by a series of
    values to use in a 'where' clause search.

    :param string collection: a :class:`sandman.model.Model` endpoint
    :param dict query_arguments: a list of filter query arguments
    :rtype: class:`sandman.model.Model`

    """
    session = _get_session()
    cls = endpoint_class(collection)
    if query_arguments:
        filters = []
        order = []
        limit = None
        for key, value in query_arguments.items():
            if key == 'page':
                continue
            if value.startswith('%'):
                filters.append(getattr(cls, key).like(str(value), escape='/'))
            elif key == 'sort':
                order.append(getattr(cls, value))
            elif key == 'limit':
                limit = value
            elif key:
                filters.append(getattr(cls, key) == value)
        resources = session.query(cls).filter(*filters).order_by(
            *order).limit(limit)
    else:
        resources = session.query(cls).all()
    return resources
def retrieve_collection ( collection , query_arguments = None ) : session = _get_session ( ) cls = endpoint_class ( collection ) if query_arguments : filters = [ ] order = [ ] limit = None for key , value in query_arguments . items ( ) : if key == 'page' : continue if value . startswith ( '%' ) : filters . append ( getattr ( cls , key ) . like ( str ( value ) , escape = '/' ) ) elif key == 'sort' : order . append ( getattr ( cls , value ) ) elif key == 'limit' : limit = value elif key : filters . append ( getattr ( cls , key ) == value ) resources = session . query ( cls ) . filter ( * filters ) . order_by ( * order ) . limit ( limit ) else : resources = session . query ( cls ) . all ( ) return resources
Return the resources in *collection*, possibly filtered by a series of
    values to use in a 'where' clause search.

    :param string collection: a :class:`sandman.model.Model` endpoint
    :param dict query_arguments: a list of filter query arguments
    :rtype: class:`sandman.model.Model`