The Python 2 -> 3 migration had a dashboard like that and developers had in the past chose the flavor of Python they would use based on the availability of the packages they needed.
One of the reasons I got into sanic recently is indeed for the speed and the simplicity of the code. Sanic is indeed growing and I think having a way of showing what key modules are used and its stability would also be encouraging to enterprises that might be interested in using this stack. If enterprises start using it, I think the popularity of sanic could also grow.
debug sanic with pycharm when
, if we want to keep
debug=True we also have to explicitly mention auto_reload=False
Is this a bug?
I'm having an issue with request.ctx and middleware.
@app.middleware('request') async def _prepare(request): request.ctx.test = '1234' @app.middleware('response') async def _cleanup(request, response): test = request.ctx.test #test = getattr(request.ctx, 'test')
I'm getting this error
AttributeError: 'types.SimpleNamespace' object has no attribute 'test'
I guess my question is if this is the same ctx as in _prepare, or if I have to do anything extra to get _cleanup the same info
I've made this small example to help recreate the issue.
from sanic import Sanic from sanic.response import HTTPResponse app = Sanic("middleware_test") @app.middleware("request") async def _prepare(request): request.ctx.test = 'ASDF' @app.middleware("response") async def _cleanup(request, response): test = request.ctx.test @app.route("/") async def test(request): test = request.ctx.test return HTTPResponse("Got Test: %s" % test, content_type='text/html') if __name__ == "__main__": app.run(host="0.0.0.0", port=8888)
If you run the code, you'll notice the handler renders the response just fine, but if you look at the console output you'll notice the traceback:
[2020-07-04 21:45:19 +0000]  [ERROR] Exception occurred in one of response middleware handlers Traceback (most recent call last): File "<path>/env/lib/python3.6/site-packages/sanic/app.py", line 977, in handle_request request, response, request_name=name File "<path>/env/lib/python3.6/site-packages/sanic/app.py", line 1281, in _run_response_middleware _response = await _response File "mwtest.py", line 12, in _cleanup test = request.ctx.test AttributeError: 'types.SimpleNamespace' object has no attribute 'test'