def add(request): vid = request.GET["vid"] if "OPENSHIFT_REPO_DIR" in os.environ: vdb = VocapDB("/stt_dir", "main", os.environ.get("OPENSHIFT_REPO_DIR")) else: vdb = VocapDB("/stt_dir", "main", "../../") vdb.add(vid) return render_to_response("add.html", {"title": vdb.title})
def delete(request): vid = request.GET["vid"] if "OPENSHIFT_REPO_DIR" in os.environ: vdb = VocapDB("/stt_dir", "main", os.environ.get("OPENSHIFT_REPO_DIR")) else: vdb = VocapDB("/stt_dir", "main", "../../") vdb.vid = vid vdb.delete_from_index() return render_to_response("add.html")
def search(request): searched_text = request.GET["search"] if "OPENSHIFT_REPO_DIR" in os.environ: filename = os.environ.get("OPENSHIFT_REPO_DIR") + "/stt_dir/search_log.txt" else: filename = "../../search_log.txt" fileobj = codecs.open(filename, "a", "utf-8") fileobj.write( strftime("%Y-%m-%d %H:%M:%S", gmtime()) + "\t" + request.META["REMOTE_ADDR"] + "\t" + searched_text + "\n" ) fileobj.close() if "OPENSHIFT_REPO_DIR" in os.environ: vdb = VocapDB("/stt_dir", "main", os.environ.get("OPENSHIFT_REPO_DIR")) else: vdb = VocapDB("/stt_dir", "main", "../../") results = vdb.search(searched_text) message = {"results": results} json = simplejson.dumps(message) return HttpResponse(json, mimetype="application/json")