PythonWin Outlook connection

Mike C. Fletcher mcfletch at home.com
Mon May 14 15:28:15 EDT 2001


Might be related to something you see with IE or the Cortona VRML control
(I'm going from old memory here, so I might be skewing the ideas slightly):

    When using MakePy, you get exactly the type of object that the typelib
declares as the return value for a method.  This is often a base
class/interface, rather than the actual type/class of the object.
Apparently PythonCOM uses the type information to choose what interface
class to use, rather than examining the object to see what interfaces are
exposed (which is, I suppose, the correct way to do it). To get at the real
object, you have to re-wrap the object:

    def castFromBase( object ):
        return win32com.client.Dispatch( object._oleobj_ )

Whereas when things are dynamic, you get the derived class directly, so the
above isn't necessary (but if I recall correctly, doesn't hurt anything).

i.e.

	field = node.getField( "children" )
	# field is now an IField object, but IField is an abstract interface
	# which doesn't know anything about anything
	field = castFromBase( field )
	# field is now an IMFNodeCollection, so can be interacted with productively
	field.Index( 0 )

Not sure if that helps, or is even relevant, but I like to hear myself talk
:) .
Mike

-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of michael montagne
Sent: May 14, 2001 14:56
To: python-list at python.org
Subject: Re: PythonWin Outlook connection


OK, got it working.  I deleted all the files in c:\python21\win32com\gen_py
and now everything works.  Can someone explain that to me?
I don't have to do that on my machine.  I thought it was better to run
makepy and enable early binding by using
objOut = win32com.client.Dispatch("Outlook.Application.9").  But now that
same line only works if I don't run makepy.
I'm afraid I don't completely understand.

-mjm
...





More information about the Python-list mailing list