def get_graph(self, request): username = request.getCookie("username") graph_id = request.args.get("graph_id", "") title = request.args.get("title", "") graph_type = request.args.get("graph_type", "") timescale = request.args.get("timescale", "") for each in [graph_id, title, graph_type, timescale]: if each == "": request.setResponseCode(400) return "" keys = request.args.keys() for each in ["graph_id", "title", "graph_type", "timescale"]: index = keys.index(each) del keys[index] graph = model.get_data_for_graph(self.__SessionMaker, graph_id, title, graph_type, keys, timescale) template = self.__template_lookup.get_template("graph.mako") return template.render( username=username, title=title, graph_type=graph_type, components=keys, graph=[graph] ).encode("utf8")
def get_graph(self, request): username = request.getCookie('username') graph_id = request.args.get('graph_id', '') title = request.args.get('title', '') graph_type = request.args.get('graph_type', '') timescale = request.args.get('timescale', '') for each in [graph_id, title, graph_type, timescale]: if each == '': request.setResponseCode(400) return '' keys = request.args.keys() for each in ['graph_id', 'title', 'graph_type', 'timescale']: index = keys.index(each) del keys[index] graph = model.get_data_for_graph(self.__SessionMaker, graph_id, title, graph_type, keys, timescale) template = self.__template_lookup.get_template('graph.mako') return template.render(username=username, title=title, graph_type=graph_type, components=keys, graph=[graph]).encode('utf8')
def get_graph(self, request): user_session = request.getSession() username = self.__user_sessions.get(user_session) title = request.args.get('title', '') graph_type = request.args.get('graph_type', '') timescale = request.args.get('timescale', '') if (title == '' or graph_type == '' or timescale == '' or len(request.args) == 3): request.setResponseCode(400) return 'Bad arguments' keys = [key for key in request.args.keys() if key not in ('title', 'graph_type', 'timescale')] graph = model.get_data_for_graph(self.__SessionMaker, title, graph_type, keys, timescale) template = self.__template_lookup.get_template('graph.mako') return template.render(username=username, title=title, graph_type=graph_type, components=keys, graph=[graph])