Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.werkzeug.contrib.sessions.FilesystemSessionStore Class Reference
Inheritance diagram for MoinMoin.support.werkzeug.contrib.sessions.FilesystemSessionStore:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.werkzeug.contrib.sessions.FilesystemSessionStore:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def get_session_filename
def save
def delete
def get
def is_valid_key
def generate_key
def new
def save_if_modified

Public Attributes

 path
 filename_template
 session_class

Detailed Description

Simple example session store that saves sessions in the filesystem like
PHP does.

:param path: the path to the folder used for storing the sessions.
             If not provided the default temporary directory is used.
:param filename_template: a string template used to give the session
                          a filename.  ``%s`` is replaced with the
                          session id.
:param session_class: The session class to use.  Defaults to
                      :class:`Session`.

Definition at line 176 of file sessions.py.


Constructor & Destructor Documentation

def MoinMoin.support.werkzeug.contrib.sessions.FilesystemSessionStore.__init__ (   self,
  path = None,
  filename_template = 'werkzeug_%s.sess',
  session_class = None 
)

Definition at line 190 of file sessions.py.

00190 
00191                  session_class=None):
00192         SessionStore.__init__(self, session_class)
00193         if path is None:
00194             from tempfile import gettempdir
00195             path = gettempdir()
00196         self.path = path
00197         self.filename_template = filename_template


Member Function Documentation

Delete a session.

Reimplemented from MoinMoin.support.werkzeug.contrib.sessions.SessionStore.

Definition at line 208 of file sessions.py.

00208 
00209     def delete(self, session):
00210         fn = self.get_session_filename(session.sid)
00211         try:
00212             # Late import because Google Appengine won't allow os.unlink
00213             from os import unlink
00214             unlink(fn)
00215         except OSError:
00216             pass

Here is the call graph for this function:

def MoinMoin.support.werkzeug.contrib.sessions.SessionStore.generate_key (   self,
  salt = None 
) [inherited]
Simple function that generates a new session key.

Definition at line 149 of file sessions.py.

00149 
00150     def generate_key(self, salt=None):
00151         """Simple function that generates a new session key."""
00152         return generate_key(salt)

Here is the caller graph for this function:

Get a session for this sid or a new session object.  This method
has to check if the session key is valid and create a new session if
that wasn't the case.

Reimplemented from MoinMoin.support.werkzeug.contrib.sessions.SessionStore.

Definition at line 217 of file sessions.py.

00217 
00218     def get(self, sid):
00219         fn = self.get_session_filename(sid)
00220         if not self.is_valid_key(sid) or not path.exists(fn):
00221             return self.new()
00222         else:
00223             f = file(fn, 'rb')
00224             try:
00225                 data = load(f)
00226             finally:
00227                 f.close()
00228         return self.session_class(data, sid, False)
00229 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 198 of file sessions.py.

00198 
00199     def get_session_filename(self, sid):
00200         return path.join(self.path, self.filename_template % sid)

Here is the caller graph for this function:

Check if a key has the correct format.

Definition at line 145 of file sessions.py.

00145 
00146     def is_valid_key(self, key):
00147         """Check if a key has the correct format."""
00148         return _sha1_re.match(key) is not None

Here is the caller graph for this function:

Generate a new session.

Definition at line 153 of file sessions.py.

00153 
00154     def new(self):
00155         """Generate a new session."""
00156         return self.session_class({}, self.generate_key(), True)

Here is the call graph for this function:

Here is the caller graph for this function:

Save a session.

Reimplemented from MoinMoin.support.werkzeug.contrib.sessions.SessionStore.

Definition at line 201 of file sessions.py.

00201 
00202     def save(self, session):
00203         f = file(self.get_session_filename(session.sid), 'wb')
00204         try:
00205             dump(dict(session), f, HIGHEST_PROTOCOL)
00206         finally:
00207             f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Save if a session class wants an update.

Definition at line 160 of file sessions.py.

00160 
00161     def save_if_modified(self, session):
00162         """Save if a session class wants an update."""
00163         if session.should_save:
00164             self.save(session)

Here is the call graph for this function:


Member Data Documentation

Definition at line 196 of file sessions.py.

Definition at line 195 of file sessions.py.

Definition at line 143 of file sessions.py.


The documentation for this class was generated from the following file: