Hi,

I did use the makepy utility through pythonwin GUI (although I'm not sure It
had any effect)

>>> cs = s.ms.Document.ComponentSet
>>> cs[4].TypeName # attribute of type Component
u'Folder'
>>> cs[4].Children # attribute of type Folder
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\ActivePython25\Lib\site-packages\win32com\client\__init__.py",
line 496, in __getattr__
    if d is not None: return getattr(d, attr)
  File "C:\ActivePython25\Lib\site-packages\win32com\client\__init__.py",
line 454, in __getattr__
    raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self),
attr)
AttributeError: '<win32com.gen_py.Manifold System Type Library.IComponent
instance at 0x39172936>' object has no attribute 'Children'
>>>

NOW APPLAYING YOUR ADVICE

>>> f = win32com.client.CastTo(cs[4],"IFolder")
>>> f.Children
<win32com.gen_py.None.ComponentSet>

So yes, I can go this way, although it's much less elegant, then automatic
casting.

Thanks a lot,

Tibor

On Wed, Jul 16, 2008 at 3:07 AM, Mark Hammond <[EMAIL PROTECTED]>
wrote:

>  You probably want to look at using makepy and see if the behaviour
> changes.
>
>
>
> Note too that the "name" displayed by win32com may not correspond to the
> type of the object at all, particularly when makepy isn't used or for
> whatever reason the object doesn't support type information.  Are you
> actually seeing a problem caused by what you describe?  If so, what?  If the
> problem is that the methods etc from the sub-class aren't seen, then check
> out win32com.client.CastTo()
>
>
>
> Cheers,
>
>
>
> Mark
>
>
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Tibor Arpas
> *Sent:* Wednesday, 16 July 2008 12:20 AM
> *To:* [email protected]
> *Subject:* [python-win32] COM Base Class and derived classes
>
>
>
> Hi,
> I'm new to both python and COM. I try to use the win32com.client. Many
> things work like a charm, but I bumped into following problem. The COM
> server has following hierarchy of types:
>
> Component (Base class)
> -----Folder
> -----Drawing
> -----Image
> -----Form
> -----Script
> ----- ......
>
> The components are stored in a collection. When I try to access specific
> component in my script I'm always getting the instance of "Component".
>
> >>> s.Document.ComponentSet['MyDrawing']
> ....  instance of Component ......
>
>
> When I try the same thing in IronPython (the COM component has also .NET
> interface and I use the clr library from IronPython), I get the specific
> type. This confirms that at least some of my assumptions are right.
>  >>>s.Document.ComponentSet["MyDrawing"]
> <DrawingClass object at 0x0000000000000031>
>
> Can anybody give some pointers where to look and what to check?
> Regards,
> Tibor
>
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to