-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New panels ideas and porting existing #11
Comments
Missing templates panel for aiohttp_jinja2, obviously. |
Currently trying to port Jinja2 debug panel. def setup(app, *args, app_key=APP_KEY, context_processors=(), **kwargs):
...
app.on_jinja2_template_rendered = signals.Signal(app)
...
def render_string(template_name, request, context, *, app_key=APP_KEY):
...
asyncio.ensure_future(app.on_jinja2_template_rendered.send(app, context))
... and subscribed on it in new debug panel: class Jinja2DebugPanel(DebugPanel):
"""
A panel to display Jinja2 template variables.
"""
name = 'Jinja2'
has_content = True
template = 'jinja2.jinja2'
title = 'Jinja2'
nav_title = title
def __init__(self, request):
super().__init__(request)
# attach handler
request.app.on_jinja2_template_rendered.append(self.on_template_rendered)
def on_template_rendered(self, app, context):
self.populate(context)
# detach handler
app.on_jinja2_template_rendered.remove(self.on_template_rendered)
def populate(self, context):
self.data = {'variables': []}
for name, value in context.items():
self.data['variables'].append((name, repr(value))) Works pretty similar to flask-debugtoolbar except they don't need to detach handler each time because there's only one request. |
Calling async signals from sync |
I've looked around for cool panel in pyramid/django/flask projects:
May be we should add some library like:
aiohttp_debugtoolbar_extras
or own repository for each task.The text was updated successfully, but these errors were encountered: