SVN: r25585 - trunk/quixote
David Binger <dbinger-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Fri, 12 Nov 2004 08:58:24 -0500
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: dbinger
Date: 2004-11-11 19:56:59 -0500 (Thu, 11 Nov 2004)
New Revision: 25585
Modified:
trunk/quixote/session.py
Log:
Adjust docstrings.
Modified: trunk/quixote/session.py
===================================================================
--- trunk/quixote/session.py 2004-11-12 00:19:39 UTC (rev 25584)
+++ trunk/quixote/session.py 2004-11-12 00:56:59 UTC (rev 25585)
@@ -1,5 +1,4 @@
-"""quixote.session
-$HeadURL$
+"""$URL$
$Id$
Quixote session management. There are two levels to Quixote's
@@ -54,8 +53,7 @@
def __init__(self, session_class=None, session_mapping=None):
- """SessionManager(session_class : class = Session,
- session_mapping : mapping = {})
+ """(session_class : class = Session, session_mapping : mapping = None)
Create a new session manager. There should be one session
manager per publisher (really SessionPublisher), ie. one
@@ -86,14 +84,14 @@
# doesn't provide all of the mapping methods needed here)
def keys(self):
- """keys() -> [string]
+ """() -> [string]
Return the list of session IDs of sessions in this session manager.
"""
return self.sessions.keys()
def sorted_keys(self):
- """sorted_keys() -> [string]
+ """() -> [string]
Return the same list as keys(), but sorted.
"""
@@ -102,14 +100,14 @@
return keys
def values(self):
- """values() -> [Session]
+ """() -> [Session]
Return the list of sessions in this session manager.
"""
return self.sessions.values()
def items(self):
- """items() -> [(string, Session)]
+ """() -> [(string, Session)]
Return the list of (session_id, session) pairs in this session
manager.
@@ -117,7 +115,7 @@
return self.sessions.items()
def get(self, session_id, default=None):
- """get(session_id : string, default : any = None) -> Session
+ """(session_id : string, default : any = None) -> Session
Return the session object identified by 'session_id', or None if
no such session.
@@ -125,7 +123,7 @@
return self.sessions.get(session_id, default)
def __getitem__(self, session_id):
- """__getitem__(session_id : string) -> Session
+ """(session_id : string) -> Session
Return the session object identified by 'session_id'. Raise KeyError
if no such session.
@@ -133,7 +131,7 @@
return self.sessions[session_id]
def has_key(self, session_id):
- """has_key(session_id : string) -> boolean
+ """(session_id : string) -> boolean
Return true if a session identified by 'session_id' exists in
the session manager.
@@ -145,7 +143,7 @@
has_session = has_key
def __setitem__(self, session_id, session):
- """__setitem__(session_id : string, session : Session)
+ """(session_id : string, session : Session)
Store 'session' in the session manager under 'session_id'.
"""
@@ -157,7 +155,7 @@
self.sessions[session_id] = session
def __delitem__(self, session_id):
- """__getitem__(session_id : string) -> Session
+ """(session_id : string) -> Session
Remove the session object identified by 'session_id' from the session
manager. Raise KeyError if no such session.
@@ -172,7 +170,7 @@
# request is finished processing.
def abort_changes(self, session):
- """abort_changes(session : Session)
+ """(session : Session)
Placeholder for subclasses that implement transactional
persistence: forget about saving changes to the current
@@ -182,7 +180,7 @@
pass
def commit_changes(self, session):
- """commit_changes(session : Session)
+ """(session : Session)
Placeholder for subclasses that implement transactional
persistence: commit changes to the current session. Called by
@@ -198,8 +196,7 @@
# level details of managing web sessions
def new_session(self, id):
- """new_session(id : string)
- -> Session
+ """(id : string) -> Session
Return a new session object, ie. an instance of the session_class
class passed to the constructor (defaults to Session).
@@ -207,7 +204,7 @@
return self.session_class(id)
def _get_session_id(self, config):
- """_get_session_id() -> string
+ """() -> string
Find the ID of the current session by looking for the session
cookie in the reques'. Return None if no such cookie or the
@@ -234,7 +231,7 @@
return self.new_session(None)
def get_session(self):
- """get_session() -> Session
+ """() -> Session
Fetch or create a session object for the current session, and
return it. If a session cookie is found in the HTTP request
@@ -278,10 +275,8 @@
session._set_access_time(self.ACCESS_TIME_RESOLUTION)
return session
- # get_session ()
-
def maintain_session(self, session):
- """maintain_session(session : Session)
+ """(session : Session)
Maintain session information. This method is called by
SessionPublisher after servicing an HTTP request, just before
@@ -329,7 +324,7 @@
return name
def set_session_cookie(self, session_id):
- """set_session_cookie(session_id : string)
+ """(session_id : string)
Ensure that a session cookie with value 'session_id' will be
returned to the client via the response object.
@@ -365,7 +360,7 @@
request.session = None
def has_session_cookie(self, must_exist=False):
- """has_session_cookie(must_exist : boolean = false) -> bool
+ """(must_exist : boolean = false) -> bool
Return true if the request already has a cookie identifying a
session object. If 'must_exist' is true, the cookie must
@@ -382,9 +377,7 @@
else:
return True
-# SessionManager
-
class Session:
"""
Holds information about the current session. The only information
@@ -437,7 +430,7 @@
return "session %s (no user)" % self.id
def has_info(self):
- """has_info() -> boolean
+ """() -> boolean
Return true if this session contains any information that must
be saved.
@@ -445,7 +438,7 @@
return self.user or self._form_tokens
def is_dirty(self):
- """is_dirty() -> boolean
+ """() -> boolean
Return true if this session has changed since it was last saved
such that it needs to be saved again.
@@ -471,14 +464,11 @@
file.write(' created %s, last accessed %s' % (ctime, atime))
file.write(' _form_tokens: %s\n' % self._form_tokens)
- # dump()
-
# -- Hooks into the Quixote main loop ------------------------------
def start_request(self):
- """start_request()
-
+ """
Called near the beginning of each request: after the HTTPRequest
object has been built and this Session object has been fetched
or built, but before we traverse the URL or call the callable
@@ -488,8 +478,7 @@
get_request().environ['REMOTE_USER'] = str(self.user)
def finish_request(self):
- """finish_request()
-
+ """
Called near the end of each request: after a callable object has
been found and (successfully) called. Not called if there were
any errors processing the request.
@@ -543,7 +532,7 @@
# -- Form token methods --------------------------------------------
def create_form_token(self):
- """create_form_token() -> string
+ """() -> string
Create a new form token and add it to a queue of outstanding form
tokens for this session. A maximum of MAX_FORM_TOKENS are saved.
@@ -557,17 +546,17 @@
return token
def has_form_token(self, token):
- """has_form_token(token : string) -> boolean
+ """(token : string) -> boolean
Return true if 'token' is in the queue of outstanding tokens.
"""
return token in self._form_tokens
def remove_form_token(self, token):
- """remove_form_token(token : string)
+ """(token : string)
Remove 'token' from the queue of outstanding tokens.
"""
self._form_tokens.remove(token)
-# Session
+