Skip to content
Browse files

SessionMixin fixed - wasn't working because of deprecated DB calls, a…

…lso wasn't creating new Sessions hen none existed. Minor documentation update.
  • Loading branch information...
1 parent e006d63 commit ad025ba388684514ae855aad73a2df3e65a4f739 @LBiNationalTrust LBiNationalTrust committed Oct 8, 2012
View
2 Documentation/docs/authentication.rst
@@ -75,7 +75,7 @@ The SessionMixin exposes some basic functionality that will let you get and set
it to the database.
All session data is stored in the SessionModel as a Base64 encoded string that is a ``dict``. To get and set session
-values is quite straightforward::
+values is quite straightforward as the session will be auto-created as soon as you start using the object::
from Mojo.Auth.Mixins.SessionMixins import SessionMixin_Sync
class loginHandler(MojoRequestHandler, SessionMixin_Sync):
View
4 Documentation/index.rst
@@ -3,8 +3,8 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-Mojo v0.1 - a framework for Tornado
-===================================
+Mojo v0.1.1 - a framework for Tornado
+=====================================
Mojo is a framework that makes it easy and quick to build Tornado projects that scale.
View
3 Mojo/Auth/Mixins/SessionMixins.py
@@ -114,7 +114,8 @@ def get_session_object(self):
if thisSessionObject is not None:
self.session.session_model = thisSessionObject
else:
- thisSessionObject = Session()
+ from Mojo.Auth.SessionManager import Setup_session
+ self.session.session_model = Setup_session(Session())
return thisSessionObject
View
8 Mojo/Auth/SessionManager.py
@@ -87,7 +87,7 @@ def _is_session_valid(self):
as the cookie expiry. Returns ``True`` or ``False``
'''
if self.session_model is not None:
- if self.session_model.session_expires.get_value() > datetime.datetime.now():
+ if self.session_model.session_expires > datetime.datetime.now():
return True
else:
return False
@@ -100,7 +100,7 @@ def _set_session_key(self, key, value):
function will go through a `check -> decode -> set` process and set the ``session_model`` attribute of the ``SesionManager``
'''
if self.session_model.session_data is not None:
- session_data = self._decode_session(self.session_model.session_data.get_value())
+ session_data = self._decode_session(self.session_model.session_data)
session_data[key] = value
else:
session_data = {key:value}
@@ -117,7 +117,7 @@ def _get_session_key(self, key):
if self._is_session_valid():
session_data = {}
if self.session_model is not None:
- session_data = self._decode_session(self.session_model.session_data.get_value())
+ session_data = self._decode_session(self.session_model.session_data)
if key in session_data:
return session_data[key]
@@ -154,7 +154,7 @@ def _create_new_session(self):
'''
new_session = Setup_session(Session())
self.session_model = new_session
- self.request_handler.set_secure_cookie('session_id', new_session.session_key.get_value())
+ self.request_handler.set_secure_cookie('session_id', new_session.session_key)
return self.session_model
def Setup_session(sessionObj, expiry_days=30, expiry_hours=0, expiry_minutes=0):

0 comments on commit ad025ba

Please sign in to comment.
Something went wrong with that request. Please try again.