Here is my session expiring handler from MyContext/__init__.py
# Need to clean up all of the wav files created by the user
from MiscUtils.MixIn import MixIn
from WebKit.Session import Session
import os,os.path
class SessionMixIn:
def expiring(self):
print 'session started', self.creationTime()
print 'ending session- removing cgPlayerGeneratedWavs'
if (self.hasValue('cgPlayerGeneratedWavs')):
fileList=self.value('cgPlayerGeneratedWavs')
for f in fileList:
if os.path.isfile(f):
os.remove(f)
# Now inject the methods from SessionMixIn into Session
MixIn(Session, SessionMixIn)
-Aaron
Scott Lewis wrote:
>hi,
>
>i'm new to webware and am having some problems with sessions. my needs
>are simple and, i imagine, common. i'm probably overlooking something.
>
>when someone logs in, i set up some data and store it in the session. if
>the session expires, i want to notify the user and have them login
>again.
>
>the docs seem to indicate that a lot of this is handled automatically.
>but when the session expires, i get a KeyError. i can't figure out how
>to detect this and generate a new, valid session.
>
>here are the session related settings in Application.config:
> 'SessionStore': 'File',
> 'SessionTimeout': 1,
> 'MaxDynamicMemorySessions': 10000,
> 'DynamicSessionTimeout': 1,
> 'SessionPrefix': None,
> 'IgnoreInvalidSession': 1,
>
>i also tried with SessionStore set to Memory and IgnoreInvalidSession
>set to 0. same behavior.
>
>the error occurs on this line in writeContent():
>
> sess = self.session()
>
>any ideas what i'm doing wrong? also, where can i do the check for an
>expired session globally so i don't have to do it for each page? in
>SitePage.awake(), with each page deriving from SitePage?
>
>thanks in advance for any help,
>
>-scott
>
>Webware version: from CVS a few days ago
>
>Traceback (most recent call last):
> File "./WebKit/Application.py", line 429, in dispatchRawRequest [edit]
> self.runTransaction(trans)
> File "./WebKit/Application.py", line 476, in runTransaction [edit]
> self.runServlet(servlet, trans)
> File "./WebKit/Application.py", line 501, in runServlet [edit]
> servlet.runTransaction(trans)
> File "./WebKit/Servlet.py", line 41, in runTransaction [edit]
> self.respond(trans)
> File "./WebKit/HTTPServlet.py", line 51, in respond [edit]
> method(trans)
> File "./WebKit/Page.py", line 60, in respondToGet [edit]
> self._respond(transaction)
> File "./WebKit/Page.py", line 102, in _respond [edit]
> self.defaultAction()
> File "./WebKit/Page.py", line 105, in defaultAction [edit]
> self.writeHTML()
> File "./WebKit/Page.py", line 211, in writeHTML [edit]
> self.writeBody()
> File "./WebKit/Page.py", line 287, in writeBody [edit]
> self.writeBodyParts()
> File "./WebKit/SidebarPage.py", line 47, in writeBodyParts [edit]
> self.writeSidebar()
> File "/home/csl/develop/python/address/SitePage.py", line 15, in
>writeSidebar [edit]
> sess = self.request().session()
> File "./WebKit/HTTPRequest.py", line 225, in session [edit]
> return self._transaction.session()
> File "./WebKit/Transaction.py", line 67, in session [edit]
> self._session = self._application.createSessionForTransaction(self)
> File "./WebKit/Application.py", line 307, in
>createSessionForTransaction [edit]
> session = self.session(sessId)
> File "./WebKit/Application.py", line 275, in session [edit]
> return self._sessions[sessionId]
> File "./WebKit/SessionFileStore.py", line 50, in __getitem__ [edit]
> raise KeyError, key
>KeyError: 20030516091053-0371d5a44d500daea3657e0213a01c31
>
>
>
>
>
>
>-------------------------------------------------------
>Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
>The only event dedicated to issues related to Linux enterprise solutions
>www.enterpriselinuxforum.com
>
>_______________________________________________
>Webware-discuss mailing list
>Webware-discuss@...
>https://lists.sourceforge.net/lists/listinfo/webware-discuss
>
>
|