def request_view(request): history = find_request_history(request) try: last_request_pair = history.last(1)[0] except IndexError: last_request_pair = None last_request_id = None else: last_request_id = last_request_pair[0] request_id = request.matchdict.get('request_id', last_request_id) toolbar = history.get(request_id, None) if not toolbar: raise NotFound static_path = request.static_url(STATIC_PATH) root_path = request.route_url(ROOT_ROUTE_NAME) button_style = get_setting(request.registry.settings, 'button_style', '') hist_toolbars = history.last(10) return {'panels': toolbar.panels, 'static_path': static_path, 'root_path': root_path, 'button_style': button_style, 'history': hist_toolbars, 'global_panels': toolbar.global_panels, 'request_id': request_id }
def find_query(self): request_id = self.request.matchdict['request_id'] all_history = find_request_history(self.request) history = all_history.get(request_id) sqlapanel = [p for p in history.panels if p.name == 'sqlalchemy'][0] query_index = int(self.request.matchdict['query_index']) return sqlapanel.queries[query_index]
def request_view(request): history = find_request_history(request) try: last_request_pair = history.last(1)[0] except IndexError: last_request_pair = None last_request_id = None else: last_request_id = last_request_pair[0] request_id = request.matchdict.get('request_id', last_request_id) toolbar = history.get(request_id, None) static_path = request.static_url(STATIC_PATH) root_path = request.route_url(ROOT_ROUTE_NAME) button_style = get_setting(request.registry.settings, 'button_style') max_visible_requests = get_setting(request.registry.settings, 'max_visible_requests') hist_toolbars = history.last(max_visible_requests) return {'panels': toolbar.panels if toolbar else [], 'static_path': static_path, 'root_path': root_path, 'button_style': button_style, 'history': hist_toolbars, 'default_active_panels': ( toolbar.default_active_panels if toolbar else []), 'global_panels': toolbar.global_panels if toolbar else [], 'request_id': request_id }
def request_view(request): history = find_request_history(request) try: last_request_pair = history.last(1)[0] except IndexError: last_request_pair = None last_request_id = None else: last_request_id = last_request_pair[0] request_id = request.matchdict.get('request_id', last_request_id) toolbar = history.get(request_id, None) static_path = request.static_url(STATIC_PATH) root_path = request.route_url(ROOT_ROUTE_NAME) button_style = get_setting(request.registry.settings, 'button_style') max_visible_requests = get_setting(request.registry.settings, 'max_visible_requests') hist_toolbars = history.last(max_visible_requests) return { 'panels': toolbar.panels if toolbar else [], 'static_path': static_path, 'root_path': root_path, 'button_style': button_style, 'history': hist_toolbars, 'global_panels': toolbar.global_panels if toolbar else [], 'request_id': request_id }
def sse(request): response = request.response response.content_type = 'text/event-stream' history = find_request_history(request) response.text = U_BLANK active_request_id = text_(request.GET.get('request_id')) client_last_request_id = text_(request.headers.get('Last-Event-Id', 0)) if history: last_request_pair = history.last(1)[0] last_request_id = last_request_pair[0] if not last_request_id == client_last_request_id: data = [[_id, toolbar.json, 'active' if active_request_id == _id else ''] for _id,toolbar in history.last(10)] if data: response.text = U_SSE_PAYLOAD.format(last_request_id, json.dumps(data)) return response
def sse(request): response = request.response response.content_type = 'text/event-stream' history = find_request_history(request) response.text = U_BLANK active_request_id = text_(request.GET.get('request_id')) client_last_request_id = text_(request.headers.get('Last-Event-Id', 0)) if history: last_request_pair = history.last(1)[0] last_request_id = last_request_pair[0] if not last_request_id == client_last_request_id: data = [[ _id, toolbar.json, 'active' if active_request_id == _id else '' ] for _id, toolbar in history.last(10)] if data: response.text = U_SSE_PAYLOAD.format(last_request_id, json.dumps(data)) return response