At 12:53 PM 12/11/01 -0800, Tavis Rudd wrote:
>On Tuesday 11 December 2001 11:15, Martin Doudoroff wrote:
> > Three session questions:
> > 1) MY BURNING QUESTION: What is the "correct" way to
> > overwrite/extend/harness the expiring() method in the Session
> > object (Session.py)? Or is there a better approach? I just want to
> > execute some logging code for a specific application on session
> > expiration. I saw some brief recent traffic about session cleanup
> > on 11/29-11/30 between bj and Jeff Tavola, but it didn't completely
> > answer the question. So far, I've only subclassed Page. Session
> > seems to be buried deeper in the code hierarchy, and subclassing it
> > seems difficult and fraught with repercussions.
>
>I can't comment on the other two, but I've tried to do something like
>this bit myself. As far as I can tell there is no simple way to do
>subclass/extend the core classes in Webware 0.6 (AppServer,
>Application, Request, SessionStore, Session, etc.).  There's some
>proposals and code floating around that could handle this in Webware
>0.7, but acceptance of those proposals and release of 0.7 is going to
>be a while yet. In the mean time, it appears you have to hack the
>WebKit code to subclass them.
>
>However, I'm sure there's some easier workaround to do what you want,
>such as writing some code to manually replace the .expiring() method
>on your sessions with a custom method.  When 0.7 is released you
>could just roll this custom method into a subclass of Session and
>scrap the replacement code.

Chuck has written some nifty code to make it easy to replace class methods 
after the fact.  It's in MiscUtils/MixIn.py.

You can put an __init__.py file into your context directory.  This gets 
imported when the appserver starts up, and is therefore a convenient place 
to put in code that needs to modify the core Webware classes.  Something 
like this should work as the contents of your __init__.py:

###############################################
from MiscUtils.MixIn import MixIn
from WebKit.Session import Session

class SessionMixIn:
     def expiring(self):
         # your implementation goes here

# Now inject the methods from SessionMixIn into Session
MixIn(Session, SessionMixin)
###############################################

Until Webware has a better way to support custom classes, this is probably 
the cleanest way to get what you want.


--

- Geoff Talvola
   [EMAIL PROTECTED]

_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to