forked from amonapp/amon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working session backend, added FormEncode
- Loading branch information
martinrusev
committed
Dec 13, 2011
1 parent
e366fda
commit ee58485
Showing
8 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import formencode | ||
from formencode import validators | ||
|
||
class CreateUserForm(formencode.Schema): | ||
username = validators.String(not_empty=True) | ||
password = validators.String(not_empty=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,6 @@ | |
Sessions module for the Tornado framework. | ||
Milan Cermak <[email protected]> | ||
This module implements sessions for Tornado. It can store | ||
session data in files or MySQL databse, Memcached, Redis | ||
and MongoDB. | ||
USAGE: | ||
====== | ||
|
@@ -198,7 +194,7 @@ def _next_regeneration_at(self): | |
return datetime.datetime.utcnow() + self.regeneration_interval | ||
|
||
def invalidate(self): | ||
"""Destorys the session, both server-side and client-side. | ||
"""Destroys the session, both server-side and client-side. | ||
As a best practice, it should be used when the user logs out of | ||
the application.""" | ||
self.delete() # remove server-side | ||
|
@@ -267,7 +263,7 @@ def deserialize(datastring): | |
|
||
class MongoDBSession(BaseSession): | ||
"""Class implementing the MongoDB based session storage. | ||
All sessions are stored in a collection "tornado_sessions" in the db | ||
All sessions are stored in a collection "sessions" in the db | ||
you specify in the session_storage setting. | ||
The session document structure is following: | ||
|
@@ -284,7 +280,7 @@ class MongoDBSession(BaseSession): | |
def __init__(self, **kwargs): | ||
super(MongoDBSession, self).__init__(**kwargs) | ||
|
||
self.db = mongo # pymongo Collection object - amon_sessions | ||
self.db = mongo # pymongo Collection object - sessions | ||
if not kwargs.has_key('session_id'): | ||
self.save() | ||
|
||
|
@@ -305,6 +301,7 @@ def save(self): | |
'user_agent': self.user_agent}, # new document | ||
upsert=True) | ||
self.db.database.connection.end_request() | ||
self.dirty = False | ||
|
||
@staticmethod | ||
def load(session_id): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters