-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
Hi
I try use debugtoolbar like this:
import asyncio
import jinja2
import aiohttp_debugtoolbar
import aiohttp_jinja2
from aiohttp import web
class IndexView(web.View):
@aiohttp_jinja2.template('index.html')
async def get(self):
return {'title': 'example aiohttp_debugtoolbar!',
'text': 'Hello aiohttp_debugtoolbar!',
'app': self.request.app}
async def exception_handler(request):
raise NotImplementedError
async def init(loop):
# add aiohttp_debugtoolbar middleware to you application
app = web.Application(loop=loop)
# install aiohttp_debugtoolbar
aiohttp_debugtoolbar.setup(app)
template = """
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
<h1>{{ text }}</h1>
<p>
<a href="{{ app.router['exc_example'].url_for() }}">
Exception example</a>
</p>
</body>
</html>
"""
# install jinja2 templates
loader = jinja2.DictLoader({'index.html': template})
aiohttp_jinja2.setup(app, loader=loader)
# init routes for index page, and page with error
app.router.add_view('/', IndexView, name='index')
app.router.add_route('GET', '/exc', exception_handler,
name='exc_example')
return app
loop = asyncio.get_event_loop()
app = loop.run_until_complete(init(loop))
web.run_app(app, host='127.0.0.1', port=9000)
I get an error in debugtoolbar-page:
builtins.TypeError
TypeError: 'IndexView' object is not iterable
Traceback (most recent call last)
File "/home/ch/code/embryo/web/venv/lib/python3.6/site-packages/aiohttp_debugtoolbar/utils.py", line 168, in __call__
_y = next(_i)
File "/home/ch/code/embryo/web/venv/lib/python3.6/site-packages/aiohttp_debugtoolbar/panels/performance.py", line 58, in resource_timer_handler
result = yield from handler(request)
TypeError: 'IndexView' object is not iterable
TypeError: 'IndexView' object is not iterable
If I use function view style - everything works correctly.
Cheban1996
Metadata
Metadata
Assignees
Labels
No labels