[Zope-dev] New-style ExtensionClass

Paul Winkler pw_lists at slinkp.com
Mon Oct 20 13:36:05 EDT 2003


On Mon, Oct 20, 2003 at 11:55:39AM -0400, Jim Fulton wrote:
> 
> I've started work on a new-style ExtensionClass. This is a port
> of ExtensionClass to new-style classes.  This will provide a number
> of advantages:
> 
> - Use of new-style class features (e.g. descriptors) in Zope objects.

woohoo!
this all sounds great.

One question about new-style ExtensionClass...
I wonder if it will address a minor gripe I have with the current 
ExtensionClass.  I spent a few minutes yesterday debugging some 
code like this:

class FooProduct(SimpleItem):

    def broken(self, obj):
        if isintance(obj, FooProduct):  # never true!
            raise TypeError 

    def working(self, obj):
        if obj.meta_type == FooProduct.meta_type:
            raise TypeError


As it turns out, isinstance(FooProduct(), FooProduct) returns false!
AFAICT it's ExtensionClass that is responsible for this surprising 
behavior.  The meta_type approach is a decent workaround, but 
it means I can't automatically detect all subclasses of FooProduct, 
which is a nice feature of isinstance.

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's MARTIAN TAB GEOLOGIST!
(random hero from isometric.spaceninja.com)



More information about the Zope-Dev mailing list