On Thursday 11 April 2002 08:01 am, Geoffrey Talvola wrote:
> I would propose a similar solution, but without methods.  Use this as
> the test in ServletFactory in place of the current assertion:
>
>         # A class is useable as a Servlet if it is derived from
> Servlet OR if it contains an _isServlet
>         # class attribute that evaluates as true.
>         if not issubclass(theClass, Servlet) and getattr(theClass,
> '_isServlet', 0):
>                 raise RuntimeError, 'blah blah blah'
>
> And then if you want to use a class not derived from Servlet as a
> servlet, you just need to do:
>
> class MyFakeServlet:
>         _isServlet = 1
>         ...
>
> The Servlet class itself doesn't need to change at all.
>
> My rationale is that this is a fixed property of a particular class,
> so it should be a class attribute, rather than a method.  Or another
> way of putting it is that you shouldn't have to instantiate the class
> to find out if it's useable as a servlet.

I agree, but then it seems we should just put _isServlet=1 in 
Servlet.py and skip the issubclass() call:

        if not getattr(theClass, '_isServlet', 0):
                raise ...

-Chuck

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

Reply via email to