mbr / flask-kvsession

A drop-in replacement for Flask's session handling using server-side sessions.
http://pythonhosted.org/Flask-KVSession/
MIT License
168 stars 53 forks source link

Postponing the session_kvstore assingment #11

Closed codehugger closed 11 years ago

codehugger commented 11 years ago

I ran into a situation where I was using redis as a kv-store and I needed to load the parameters for the redis connection from the flask app after the extension had been instantiated (I have a setup where all extensions are in a separate file called extensions.py).

My changes allow the KVSessionExtension to be initialized without initial parameters and also supports the delayed assignment of the session_kvstore paramter. If session_kvstore is not provided in either init or init_app a ValueError is thrown. Hope you like the addition :)

cheers, Bjarki

mbr commented 11 years ago

That sounds like an idea worth investigating. However, I cannot pull this because the pull request isn't clean: It changes the indentation in locations not relevant for this feature and also adds a .gitignore file that doesn't belong there.

It's also a nice reminder that I have "write redis backend" still on my agenda for simplekv =/.

mbr commented 11 years ago

I've made changes to the structure of Flask-KVSession, session storage is now attached to the application, which is more in line with how Flask-Applications should behave. This adds all the benefits of the pull request mentioned here.

Also, this should work nicely with the new Redis-Backend in simplekv.

Closing this pull request. =)