Mixin class error

Kent Johnson kent at kentsjohnson.com
Tue Mar 7 02:08:31 CET 2006

Ed Leafe wrote:
>     In Dabo, we create cursor classes that combine the backend-specific  
> dbapi cursor class with our own mixin class that adds framework- 
> specific behaviors. This has been working well for a couple of years  
> now with many different backends, but today I'm getting errors with  our 
> Firebird class. I've checked the kinterbasdb site, and found  nothing 
> there that was helpful. The error reads:
> TypeError: Error when calling the metaclass bases
>     type 'kinterbasdb.Cursor' is not an acceptable base type
>     Here's some simple code that will generate the error:
> import kinterbasdb
> KCursor = kinterbasdb.Cursor
> class TestMixin(object): pass
> # This next line will raise the error.
> class CombinedCursor(TestMixin, KCursor): pass
> myCursor = CombinedCursor()
>     I'm not sure exactly what this error message means, so I don't know  
> how to go about fixing it.

I have no clue but googling 'type is not an acceptable base type' finds 
this thread

which points to the Py_TPFLAGS_BASETYPE. This example

shows that flag being set to indicate that an extension class may be 
subclassed; the API docs confirm this:

So it looks like kinterbasdb.Cursor is a C extension class that may not 
be subclassed because Py_TPFLAGS_BASETYPE is not set. Whether this is by 
design or accident would be a question for the kinterbasdb developers.

One workaround might be to use delegation instead of subclassing...


More information about the Python-list mailing list