You can convert it to a "friendly" object simply by doing:
 
locator = win32com.client.Dispatch(locator)
 
If you want to ensure early binding, try:
 
locator = win32com.client.gencache.EnsureDispatch(locator)
 
That should generate a makepy file for the interface on the fly (but doesn't
work for all objects - suck it and see :)
 
Mark

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Greg Lee
Sent: Thursday, 3 February 2005 9:55 AM
To: [email protected]
Subject: [python-win32] Working with a PyIDispatch object



I'm using MSXML2.SAXXMLReader.4.0 to validate XML.  
Following a hint posted July 2 by the estimable Mark Hammond, I implemented
the error handler thus: 

class MyErrorHandler: 
    _com_interfaces_ = ['IVBSAXErrorHandler'] 
    _public_methods_ = ['error', 'fatalError', 'ignorableWarning'] 

    def error(self, locator, strError, nErrorCode): 
  .... 

When the error method is called, the locator turns out to be a PyIDispatch
object for a win32com.gen_py.Microsoft XML, v4.0.IVBSAXLocator instance.
The only way I've found to decode this locator is via the Invoke method,
e.g.:

    def error(self, locator, strError, nErrorCode): 
        id =  locator.GetIDsOfNames('columnNumber') 
        colno = locator.Invoke(id, 0x0, pythoncom.DISPATCH_PROPERTYGET, 1) 
        ... 

1.  Is there a better way to do this?  
2.  What are the parameters for the Invoke method?  I worked this out
experimentally from win32com/dynamic.py, but I'd be happier knowing what the
"1" means.

<<attachment: winmail.dat>>

_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to