Ian Bicking wrote:
> Geoffrey Talvola wrote:
>> I think I agree with you, Jason -- Webware should provide an easy
>> hook to swap in a subclass for a key class like Session and it
>> shouldn't feel like a hack.  The Mixin stuff feels like too much of
>> a hack, and adding a bunch of hooks at specific places in the code
>> just adds clutter. 
>> 
>> Perhaps a setting in Application.Config could specify classes to use
>> in place of the standard classes:
>> 
>> 'CustomClasses':
>>      {
>>              'Session': 'MyPackage.MyModule:MySession' ,
>>              'Request': 'MyPackage.MyModule:MyRequest'
>>      }
> 
> I think this allows customizability, but not extensibility.  It's
> customizable because you can alter the appserver without modifying the
> main source.  But it's not extensible, because it can only be done
> once per installation for each main class.

Here's an idiom (completely untested) that allows you to easily do whatever
composing/extending you need.  When you define your "enhanced" Session
class, make it available as a pure Mixin (without Session as a base class)
and also as a subclass of Session like this:

# MySession1.py
from WebKit.Session import Session

class MySession1Mixin(object):
        def expiring(self):
                super(MySession1Mixin, self).expiring(self)
                #...

class MySession1(MySession1Mixin, Session):
        pass


# MySession2.py
from WebKit.Session import Session

class MySession2Mixin(object):
        def expiring(self):
                super(MySession2Mixin, self).expiring(self)
                #...

class MySession2(MySession2Mixin, Session):
        pass

If you just want MySession1 or MySession2 you use it directly.  But you can
combine the 2 mixins easily if needed:

# MySession1And2.py
from WebKit.Session import Session
from MySession1 import MySession1Mixin
from MySession2 import MySession2Mixin

class MySession1And2(MySession1Mixin, MySession2Mixin, Session):
        pass


I think this would automatically call the expired methods of
MySession1Mixin, MySession2Mixin, and Session in sequence, if I understand
the "super" mechanism properly.

- Geoff


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to