473,398 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

deriving classes from object extensions

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

Dec 7 '06 #1
1 1571
On 7 Dec 2006 16:12:18 -0800, manstey <ma*****@csu.edu.auwrote:
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/
Dec 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bo Peng | last post by:
Dear Python group: I am planning on an application that involves several complicated C++ classes. Basically, there will be one or two big data objects and some "action" objects that can act on...
28
by: Steven T. Hatton | last post by:
This may be another question having an obvious answer, but I'm not seeing it. I'm trying to create a class that derives from std::valarray<std::string>. I don't need a template, and I haven't come...
5
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
0
by: Ewart MacLucas | last post by:
generated some WMI managed classes using the downloadable extensions for vs2003 from mircrosoft downloads; wrote some test code to enumerate the physicall processors and it works a treat, but a...
4
by: Confused Newbie | last post by:
I'm converting an app written in VB 2003 to 2005 and need advice for how to deal with this situation: The app has a number of "manager" classes that handle the data access. They all have...
15
by: Nindi73 | last post by:
HI If I define the class DoubleMap such that struct DoubleMap : public std::map<std::string, double>{}; Is there any overhead in calling std::map member functions ? Moreover are STL...
12
by: Shraddha | last post by:
Can I stop people by deriving my class? I mean I don't want my class to be as a base class... Can I do that?
17
by: mosfet | last post by:
Could someone tell me why it's considered as bad practice to inherit from STL container ? And when you want to customize a STL container, do you mean I need to write tons of code just to avoid to...
1
by: Christopher Pisz | last post by:
I set out to make a custom logger. Examining some other code laying around, I came across one that derived from ostream, and had a associated class derived from streambuf. Is this practice a good...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.