Indranil Sinharoy via python-win32 wrote: > > I am a relatively new user of pywin32 package, but not Python. I have > an application (written in C/#, as I understand) that provides a COM > interface for using with other languages such as Python. I am using > the pywin32 library to communicate with the application and it works > fairly well. However, I am facing a particular kind of problem. The > problem is that the application exposes some interface objects that > inherit from other base objects but the methods defined in the base > class objects doesn't seem to be accessible to the child class object. > Is this type of behavior is atypical with pywin32?
I'm wondering about your terminology, and I may have misunderstood your situation. If you are given a COM interface, you can access the methods of that interface, or you can query for another COM interface from the same object. You certainly cannot access the non-COM methods of the underlying object. There is simply no generic way to find those methods, because they are implemented differently in different languages. That's why COM was invented -- it is language-independent. Also remember that, even though YOU know there is an object underneath, that's secret knowledge. All you are supposed to know about is a COM interface -- a set of functions. You can't rely on anything else, and you aren't supposed to know about parent/child relationships. Now, if you are talking about asking an interface to return you another interface from the same object, then the CastTo method you are using is exactly right: > class MyBaseClass: > ... > ... > def my_parent_method(self): > base = win32com.client.CastTo(self, 'MyParentClass') > return base.my_parent_method() > ... That's a fairly efficient operation. It just calls QueryInterface. > Although this strategy works, I would like to find out if there is a > more efficient/ automatic way of resolving this issue. In my > particular case, there are a large number of such objects (that > inherit from some base class without access to the methods defined in > the parent class) provided by the application and I would like to > avoid re-writing all the methods for all such objects. To a certain extent, this represents a design flaw in the objects you are invoking. When you have a lot of COM interfaces, each with a few methods, you end up doing an awful lot of QueryInterface calls. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32