[Zope-dev] handling exception in dict lookup during URL untangling; and sessions

Michael Olivier mo@local2me.com
Sun, 06 Jun 1999 04:48:23 +0000


Hi folks,

I'm subclassing the BoboDictionary class from a while ago to do sessions
(not versions, but tracking user sessions at the web site).  I cannot
assume cookies are available for my users, so I'm using a session code
as part of the URL, e.g., localhost/sess/RQZ/someObject, where RQZ is
the session ID.

    def __getitem__(self,key):
        # override this one function of BoboDictionary

        try:
            session = self.buffer[key]
            session.accessed()
            return session
        except:
            raise DMSessionMgrSessionExpired


The problem I'm having is that when the session times out, my code
raises a DMSessionMgrSessionExpired exception which I haven't figured
out how to trap somewhere because it happens during Zope's untangling of
the URL.  I can't return a web page from this function (__getitem__()).

I'd like it to show an explanatory (error) page to the user, with a link
to login again. I could create a "dummy" session ID, which __getitem__()
would return, and then all functional entry points would have to
recognize that dummy ID and go to the error page.  That's pretty
painful.  Is there a better approach I could take?

And re. sessions in general -- is sessions support coming in Zope?  I
have code I could contribute along these lines if it would help.

thanks!
Michael