web.Application and web_urldispatcher.UrlDispatcher can't be used separately #1373
Closed
Description
Long story short
Since aiohttp 1.1.0 there's no correct way to create web.Application and web_urldispatcher.UrlDispatcher separately, since the latest requires the former as argument and both saves each other as protected properties.
app = web.Application(
router=web_urldispatcher.UrlDispatcher(app), # app doesn't exist yet!
)possible solutions is to patch protected property:
# either on router
app = web.Application(router=web_urldispatcher.UrlDispatcher(None))
app.router._app = app
# or on application
app = web.Application()
app._router = web_urldispatcher.UrlDispatcher(app)aiohttp users can't rely on protected attributes, since they may changed from version to version.
Expected behaviour
There should be a proper way to resolve this solution.
Actual behaviour
Workaround is needed.
Steps to reproduce
- Create
web_urldispatcher.UrlDispatcherindependently and pass it toweb.Application.
Your environment
- aiohttp 1.1.0
- macOS sierra, Arch Linux