'Load filters
GET filter.json or GET filter.json?load=<id>
@param r: the S3Request
@param attr: additional controller parameters'

def _load(self, r, **attr):

    db = current.db
    table = current.s3db.pr_filter
    auth = current.auth
    if auth.s3_logged_in():
        pe_id = current.auth.user.pe_id
    else:
        pe_id = None
    if (not pe_id):
        r.unauthorized()
    query = (((table.deleted != True) & (table.resource == self.resource.tablename)) & (table.pe_id == pe_id))
    load = r.get_vars.get('load')
    if load:
        record_ids = [i for i in load.split(',') if i.isdigit()]
        if record_ids:
            if (len(record_ids) > 1):
                query &= table.id.belongs(record_ids)
            else:
                query &= (table.id == record_ids[0])
    else:
        record_ids = None
    rows = db(query).select(table.id, table.title, table.description, table.query)
    filters = []
    for row in rows:
        filters.append({'id': row.id, 'title': row.title, 'description': row.description, 'query': (json.loads(row.query) if row.query else [])})
    current.response.headers['Content-Type'] = 'application/json'
    return json.dumps(filters, separators=SEPARATORS)
