Title: 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.

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

Reply via email to