playpauseandstop / Flask-And-Redis

Simple as dead support of Redis database for Flask applications
http://flask-and-redis.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
84 stars 21 forks source link

Init_app doesn't set self.app = app #22

Open springrid opened 5 years ago

springrid commented 5 years ago

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.

vlade11115 commented 5 years ago

Try this.

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

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

playpauseandstop commented 4 years ago

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.