Chuck wrote:
>It's unfortunate that Python places so much emphasis on global
>functions:
> isinstance(obj, Class)
>
>Over methods:
> obj.isinstance(Class)
>
>Otherwise you could override this easily for your delegation case. Does
>isinstance() happen to call one those quadruple underscore methods by
>any chance?
Actually, the problem is just in line 183 of ServletFactory, where you see
the following assertion:
assert issubclass(theClass, Servlet)
Your question does suggest a potential solution though. How we add the
following method in Servlet:
def isServletSubclass(self):
return issubclass(self, Servlet)
Then, when we need to use delegation, the delegating servlet, which is not
a subclass of Servlet simply defines:
def isServletSubclass():
return 1
>How has Cheetah been modified such that you can't use multiple
>inheritance? Isn't that a Python thing, or is this an issue with an
>#extend directive or something similar?
The #extends directive now takes just one argument. Multiple inheritance is
still possible if you inherit from a logic class that itself does multiple
inheritance; it's just that the Cheetah template itself will only accept
one base class.
>It doesn't feel like the above example really deals with weak
>encapsulation and such since all unknown attributes just get passed on
>to the delegate anyway. That's almost like implementing your own
>inheritance. Maybe the example is just over-simplified.
Yes, it's just oversimplified... Some of the links in my message had really
decent discussion of the issues though.
>Can you inherit from Servlet, but then use the new __getattribute__ in
>a such a way to get the behavior you want?
Is this a Pythonn 2.2 thing? I'm still on Python 2.1 since I haven't read
that Webware is Python 2.2 safe...
>If not, then the final solution that comes to my mind is to tweak
>WebKit like so:
>
> if not isinstance(servlet, Servlet) and \
> not getattr(servlet, 'isServlet', None):
> raise ValueError, 'The instance is not a servlet.'
>
>e.g., for those developers that really know what they're doing, an
>"isServlet = 1" attr will bypass the test. It would be expected that an
>instance never revert to "isServlet=0" after being served up by WebKit.
Does the same thing as what I wrote above, except that I think you should
use issubclass and not isinstance...
...Edmund.
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss