This is a question as much as an issue. I have several jsonrpc methods that require db, redis, and other state/config access that would normally be passed using the the 'app' or 'request' object. What is the best method to access the parent http request and/or web app object from a method?
It seems like its necessary to modify/create/subclass:
I will be making these changes for use in our projects (jussi,yo,sbds,hivemind).
I'm thinking that changing the signature of the dispatch method (and all the other methods that lead to the jsonrpc method) to also accept *args, **kwargs
is the best, most modular way:
async def handle(aio_http_request):
statsd = aio_http_request.app.config['statsd_client']
jsonrpc_request = await aio_http_request.text()
response = await methods.dispatch(jsonrpc_request, aio_http_request, statsd=statsd)
return web.json_response(response)
I presume the use case for db/cache/metrics isn't rare, so I thought I would solicit your expertise and opinion about how these changes are implemented, especially if you're interested in adding my changes upstream.
Thanks for you excellent work!