Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session.destroy() throws an error - AttributeError: 'KVSession' object has no attribute 'sid_s' #2

Closed
t20 opened this issue Dec 14, 2011 · 9 comments

Comments

@t20
Copy link

t20 commented Dec 14, 2011

Should the init method set sid_s?

Rough output from error page.

File "/..../testapp.py", line 475, in load_signed_request

session.destroy()

[console ready]
>>> session <KVSession {}>
>>>

File "/..../python2.7/site-packages/Flask_KVSession-0.4dev-py2.7.egg/flaskext/kvsession.py", line 132, in destroy

if self.sid_s:

[console ready]
>>> self flaskext.kvsession.KVSession({})
>>> self.store <simplekv.memory.DictStore object at 0x101b3b950>
>>> dir(self) ['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'clear', 'copy', 'destroy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'modified', 'new', 'on_update', 'permanent', 'pop', 'popitem', 'regenerate', 'setdefault', 'store', 'update', 'values', 'viewitems', 'viewkeys', 'viewvalues'  ]
>>>

AttributeError: 'KVSession' object has no attribute 'sid_s'

mbr added a commit that referenced this issue Dec 16, 2011
@mbr
Copy link
Owner

mbr commented Dec 16, 2011

Hey,

thanks for reporting the issue. Can you please check if the one-line fix of c58e4ca resolves the issue?

@t20
Copy link
Author

t20 commented Dec 16, 2011

Thanks. I made the same fix earlier and it works. Thanks for the quick fix, appreciate it.

@mbr
Copy link
Owner

mbr commented Dec 18, 2011

Can you share some insight on how you triggered the error? Is it possible that open_session did not get called before?

@mbr mbr closed this as completed Dec 18, 2011
@t20
Copy link
Author

t20 commented Dec 19, 2011

It is very likely that I made a mistake and called session.destroy() in the before_request method, where the open session may not have been called yet.

Do I have to explicitly call open_session or is it handled by the application?

@mbr
Copy link
Owner

mbr commented Dec 19, 2011

It's called by flask itself, as part of the API. See http://flask.pocoo.org/docs/api/#flask.sessions.SessionInterface.open_session

mbr added a commit that referenced this issue Dec 19, 2011
@t20
Copy link
Author

t20 commented Dec 19, 2011

Either way, is it not a good idea to initialize the var anyway?

@mbr
Copy link
Owner

mbr commented Dec 19, 2011

No, because if you're not supposed to/allowed to call it before the
session is initialized you're just silently swallowing a programming
error this way.

The "best" way would probably be finding out if the session has been
opened yet and throwing a "custom" Exception that tells the user that
he really should not be doing this. But that's quite a bit of code +
testing for what seems to be an edge case.

On Mon, Dec 19, 2011 at 8:06 AM, Bharadwaj Parthasarathy
reply@reply.github.com
wrote:

Either way, is it not a good idea to initialize the var anyway?


Reply to this email directly or view it on GitHub:
#2 (comment)

@t20
Copy link
Author

t20 commented Dec 19, 2011

Agreed, Thanks. Just wrapped it in try catch for now.

Where should I post questions about flask KV session? Is there a mailing list?
These are ideas / howto / feature requests.

@mbr
Copy link
Owner

mbr commented Dec 19, 2011

For feedback, write me a message on github or if need be, open an issue. That's easiest to handle. Since this extension is so small in scope, a mailinglist or anything else seems like overkill at the moment.

ralfonso pushed a commit to ralfonso/flask-kvsession that referenced this issue Oct 17, 2012
ralfonso pushed a commit to ralfonso/flask-kvsession that referenced this issue Oct 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants