def container_issnl_stats(issnl): if not (len(issnl) == 9 and issnl[4] == '-'): abort(400, "Not a valid ISSN-L: {}".format(issnl)) try: container = api.lookup_container(issnl=issnl) except ApiException as ae: raise ae try: stats = get_elastic_container_stats(container.ident, issnl=container.issnl) except (ValueError, IOError) as ae: app.log.error(ae) abort(503) return jsonify(stats)
def container_lookup(): extid = None for key in ('issnl', 'wikidata_qid'): if request.args.get(key): extid = key break if extid is None: abort(400) try: resp = api.lookup_container(**{extid: request.args.get(extid)}) except ApiException as ae: abort(ae.status) return redirect('/container/{}'.format(resp.ident))
def container_lookup(): return generic_lookup_view('container', 'container_lookup.html', ('issnl', 'wikidata_qid'), lambda p: api.lookup_container(**p))