def get(self, route): auth_layout = None q_string = self.request.query extra_scripts = [] status = getStatus(self) if status == 1: auth_layout = Template(filename="%s/layout/authentication/login_ctrl.html" % static_path).render() # first, let's see if you have any user files if checkForAdminParty(): auth_stopgap = Template( filename="%s/layout/authentication/admin_party.html" % static_path ).render() else: auth_stopgap = Template( filename="%s/layout/errors/error_not_logged_in.html" % static_path ).render() extra_scripts = Template( filename="%s/layout/authentication/disable_user.html" % static_path ).render() self.finish(main_layout.render( template_content=auth_stopgap, authentication_holder='', search_ctrl='', extra_scripts=extra_scripts, authentication_ctrl=auth_layout, data='' )) return if route is not None: url = "%s%s" % (uurl, route) else: url = "%ssubmissions/" % uurl print url format = None as_search_result = False if q_string != "": for kvp in self.request.query.split("&"): key_val = kvp.split("=") if key_val[0] == "format": format = key_val[1] q_string = q_string.replace("format=%s" % key_val[1], "") break if not q_string.startswith("?"): q_string = "?%s" % q_string if re.search(r'&&', q_string): q_string = q_string.replace("&&","&") if re.search(r'.*&$', q_string): q_string = q_string[:-1] if re.search(r'^\?&.*', q_string): q_string = q_string.replace("?&","?") if q_string == "?": q_string = "" if q_string != "": as_search_result = True if status == 0 and not self.validateUnprivilegedQuery(q_string): print self.validateUnprivilegedQuery(q_string) self.redirect('/') return print "%s%s" % (url, q_string) try: r = requests.get("%s%s" % (url, q_string)) except requests.exceptions.ConnectionError as e: error_tmpl = Template(filename="%s/layout/errors/error_no_api.html" % static_path) self.finish(main_layout.render( template_content=error_tmpl.render(), data={}, authentication_holder='', search_ctrl='', extra_scripts='', authentication_ctrl='' )) return tmpl_extras = [] if format: self.write(r.text.replace(assets_path, "")) else: if route is not None: route = route.split("/") route[:] = [word for word in route if word != ''] if len(route) >= 3 and route[0] == "submission" and route[2] in media_routes: if route[2] == media_routes[0]: self.finish(r.text.replace(assets_path, "")) elif route[2] == media_routes[1]: self.set_header("Content-Type", r.headers['content-type']) self.finish(r.content) return layout = route[0] tmpl_extras.extend(self.getExtraTemplatesByStatus(status, route[0], as_search_result)) else: if status == 0: layout = "main_public" else: layout = "main" if status == 2 or status == 3: auth_layout = "logout_ctrl" extra_scripts.append(Template( filename="%s/layout/authentication/enable_user.html" % static_path ).render()) else: extra_scripts.append(Template( filename="%s/layout/authentication/disable_user.html" % static_path ).render()) tmpl = Template(filename="%s/layout/%s.html" % (static_path, layout)) authentication_holder = '' if status != 0: auth_tmpl = Template(filename="%s/layout/authentication/%s.html" % (static_path, auth_layout)) authentication_holder = auth_tmpl.render() authentication_ctrl = '' if status == 3: authentication_ctrl = Template( filename="%s/layout/authentication/admin_ctrl.html" % static_path ).render() search_ctrl = Template( filename="%s/layout/searches/search_ctrl.html" % static_path ).render() extra_scripts.extend(self.getExtraScriptsByStatus(status, route)) data = json.loads(r.text.replace(assets_path, "")) self.finish(main_layout.render( template_content=tmpl.render(extras="".join(tmpl_extras)), authentication_holder=authentication_holder, search_ctrl=search_ctrl, extra_scripts="".join(extra_scripts), authentication_ctrl=authentication_ctrl, data=json.dumps(data) )) print extra_scripts