Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Expose an expire method for Sessions objects
  • Loading branch information
eriol committed Jul 24, 2016
1 parent c9b9eb0 commit a0bdf7e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions circuits/web/sessions.py
Expand Up @@ -64,6 +64,10 @@ def __init__(self, name="circuits.session", channel=channel):
def load(self, sid):
return self._data[sid]

def expire(self, sid):
"""Expire session for sid."""

This comment has been minimized.

Copy link
@spaceone

spaceone Jul 24, 2016

Contributor

self._data.pop(sid, None) would be better imho.

This comment has been minimized.

Copy link
@eriol

eriol Jul 24, 2016

Author Member

I'll be happy to change it, anyway I have to wrote test before to trasform this in a PR.

I did used del so client code will notified if it's expiring a not existing Session, but if is better to not fail whatever sid is passed, I'm fine. It can be harder to detect if client code is, erroneously, expiring a sid that not exist, but well not so hard anyway. I tend to follow "error should never pass silently", mantra, but I'm less experienced of you about circuits codebase, so if semantically it's better to silence, I'm perfectly fine with the change. I will update the docstring so client code will be aware. All IMHO :)

This comment has been minimized.

Copy link
@eriol

eriol Jul 24, 2016

Author Member

@spaceone do you have any example about Sessions subclass? I would like to see them as a starting point for tests. Thanks!

del self._data[sid]

def save(self, sid, data):
"""Save User Session Data for sid"""

Expand Down

1 comment on commit a0bdf7e

@prologic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Please sign in to comment.