Skip to content

Commit

Permalink
Fixed init method to be called like SessionBase. Fixed infinite loop …
Browse files Browse the repository at this point in the history
…in exists method. Redis-py does not throw an exception when it does't find a key.
  • Loading branch information
chrisjones-brack3t committed Apr 6, 2011
1 parent 8af5403 commit b5285bd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions redis_sessions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class SessionStore(SessionBase):
"""
Implements Redis database session store.
"""
def __init__(self, *args, **kwargs):
super(SessionStore, self).__init__(*args, **kwargs)
def __init__(self, session_key=None):
super(SessionStore, self).__init__(session_key)
self.server = Redis(
host=getattr(settings, 'SESSION_REDIS_HOST', 'localhost'),
port=getattr(settings, 'SESSION_REDIS_PORT', 6379),
Expand All @@ -31,11 +31,9 @@ def load(self):
return {}

def exists(self, session_key):
try:
self.server[session_key]
except:
return False
return True
if self.server.get(session_key):
return True
return False

def create(self):
while True:
Expand Down

0 comments on commit b5285bd

Please sign in to comment.