def tag_browser(ctx, rd): ''' Get the Tag Browser serialized as JSON Optional: ?library_id=<default library>&sort_tags_by=name&partition_method=first letter &collapse_at=25&dont_collapse=&hide_empty_categories=&vl='' ''' db, library_id = get_library_data(ctx, rd)[:2] opts = categories_settings(rd.query, db) vl = rd.query.get('vl') or '' etag = cPickle.dumps([db.last_modified().isoformat(), rd.username, library_id, vl, list(opts)], -1) etag = hashlib.sha1(etag).hexdigest() def generate(): return json(ctx, rd, tag_browser, categories_as_json(ctx, rd, db, opts, vl)) return rd.etagged_dynamic_response(etag, generate)
def tag_browser(ctx, rd): ''' Get the Tag Browser serialized as JSON Optional: ?library_id=<default library>&sort_tags_by=name&partition_method=first letter &collapse_at=25&dont_collapse=&hide_empty_categories=&vl='' ''' db, library_id = get_library_data(ctx, rd)[:2] opts = categories_settings(rd.query, db) vl = rd.query.get('vl') or '' etag = cPickle.dumps([db.last_modified().isoformat(), rd.username, library_id, vl, list(opts)], -1) etag = hashlib.sha1(etag).hexdigest() def generate(): return json(ctx, rd, tag_browser, categories_as_json(ctx, rd, db, opts, vl)) return rd.etagged_dynamic_response(etag, generate)