On 7 Dec 2006 16:12:18 -0800, manstey <[EMAIL PROTECTED]> wrote: > Hi, > > I am using Python with Cache dbase, which provides pythonbind module, > and intersys.pythonbind.object types. But I can't create a class based > on this type: > > import intersys.pythonbind > class MyClass(intersys.pythonbind.object): > pass > > gives me the error: TypeError: Error when calling the metaclass bases > type 'intersys.pythonbind.object' is not an acceptable base type > > Can anyone expain if it is possible for me to derive my own class from > the intersys object so as to add my own functionality? > > thanks, > matthew > > -- > http://mail.python.org/mailman/listinfo/python-list >
Sounds like they are following outdated APIs before the new-style classes. The builtin types have been updated to be compatible with the newstyle classes, but your example is of an extension type that does not have such treatment. It simply is not inheritable, because it is from the era where one could not derive from any builtin types. The only solution you really have to use delegation instead of inheritence. Create your class by itself, give it a reference to an instance of intersys.pythonbind.object, and have it look for expected attributes there. To be a little nicer, you could have a special __getattr__ method to look up unfound attributes on the delegation object, your intersys.pythonbind.object instance. class Delegating(object): def __init__(self, old_object): self._old_object = old_object def __getattr__(self, name): return getattr(self._old_object, name) d = Delegating(my_old_object) d.my_old_attribute -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list