else: abort(404) # this is a catch-all that allows us to present everything as a search # typical catches are /user, /user/collection, /user/collection/record, # /implicit_facet_key/implicit_facet_value # and any thing else passed as a search @app.route('/<path:path>', methods=['GET', 'POST', 'DELETE']) def default(path): log.debug("default as search") log.debug(path) log.debug(current_user) import bibserver.search searcher = bibserver.search.Search(path=path, current_user=current_user) return searcher.find() if __name__ == "__main__": if config["allow_upload"]: bibserver.ingest.init() if not os.path.exists('ingest.pid'): ingest = subprocess.Popen(['python', 'bibserver/ingest.py']) open('ingest.pid', 'w').write('%s' % ingest.pid) try: bibserver.dao.init_db() app.run(host='0.0.0.0', debug=config['debug'], port=config['port']) finally: if os.path.exists('ingest.pid'): os.remove('ingest.pid')
else: abort(404) # this is a catch-all that allows us to present everything as a search # typical catches are /user, /user/collection, /user/collection/record, # /implicit_facet_key/implicit_facet_value # and any thing else passed as a search @app.route('/<path:path>', methods=['GET','POST','DELETE']) def default(path): log.debug("default as search") log.debug(path) log.debug(current_user) import bibserver.search searcher = bibserver.search.Search(path=path,current_user=current_user) return searcher.find() if __name__ == "__main__": if config["allow_upload"]: bibserver.ingest.init() if not os.path.exists('ingest.pid'): ingest=subprocess.Popen(['python', 'bibserver/ingest.py']) open('ingest.pid', 'w').write('%s' % ingest.pid) try: bibserver.dao.init_db() app.run(host='0.0.0.0', debug=config['debug'], port=config['port']) finally: if os.path.exists('ingest.pid'): os.remove('ingest.pid')
c['implicit_facet'][bits[0]] = bits[1] elif len(bits) == 1: # send request through as an implicit facet on type, if said type exists qry = 'type' + config["facet_field"] + ':' + bits[0] check = bibserver.dao.Record.query(q=qry,size=1) if check["hits"]["total"] != 0: c['implicit_facet']["type"] = bits[0] args['terms']["type"+config["facet_field"]] = [bits[0]] else: # otherwise just show a listing of the facet values for that key if 'q' in args: qryval = args['q'] else: qryval = "*:*" result = bibserver.dao.Record.query(q=qryval,facet_fields=[bits[0]+config["facet_field"]]) vals = result["facets"][bits[0]+config["facet_field"]]["terms"] #return render_template('search/listing.html', vals=vals) # get results and render results = bibserver.dao.Record.query(**args) args['path'] = path c['io'] = bibserver.iomanager.IOManager(results, args) return render_template('search/index.html', c=c) if __name__ == "__main__": bibserver.dao.init_db() app.run(host='0.0.0.0', debug=True)