Flask-And-Redis icon indicating copy to clipboard operation
Flask-And-Redis copied to clipboard

Init_app doesn't set self.app = app

Open springrid opened this issue 6 years ago • 2 comments

Awesome plugin! However, I'm using the app factory pattern and I'm struggling to get it working. It seems to me that maybe self.app = app should be added in the init_app method?

For example in create_app()::

redis_object.init_app(app)
print(redis_object.get_app())

last row will throw RuntimeError: Flask application not registered on Redis instance and no applcation bound to current context.

springrid avatar Mar 24 '19 20:03 springrid

Try this.

redis_object.init_app(app)
with app.app_context():
    print(redis_object.get_app())

http://flask.pocoo.org/docs/1.0/appcontext/

vlade11115 avatar Mar 26 '19 08:03 vlade11115

It's been a while.

I'll take a look on the original issue and if only way for redis_object.get_app() to be called within app context, I'll point this in documentation.

Thanks for waiting on this.

playpauseandstop avatar Feb 21 '20 04:02 playpauseandstop