win32com and "collection"

Jess Austin (AT) jesszworg.com
Wed May 28 02:08:42 EDT 2003


hi,

I'm having some trouble passing a "collection" to a COM function that is
expecting it.  I've tried the collection included in win32com.server.util,
and I've also tried several I've written myself.  I've tried early and late
binding.  The following is the description of this function that is found in
the file generated by makepy:

def ProcessData(self, collection=defaultNamedNotOptArg,
                                num=defaultNamedNotOptArg):
    return self._ApplyTypes_(1610809371, 1, (24, 0), ((16393, 3), (16387,
3)),
                                'ProcessData',  None, collection, num)

The first argument should be a collection.  That is, the COM service is
expecting something that supports Count() and Item().  Evidently
_ApplyTypes_ is expecting something that is both VT_BYREF and
VT_DISPATCH.  I just can't seem to give it that.  No matter what I call
ProcessData with, I get a type mismatch.  I think that it's coming from the
pythoncom library, not from the COM service I'm accessing, because
previous errors I've gotten from the COM service have been much more
detailed:

>>> from win32com.server import util
>>> from win32com import client
>>> col = util.NewCollection([])
>>> obj = client.Dispatch('FooServer.BarObject')
>>> obj.ProcessData(col, 4)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "<COMObject SFServerTC.cTimeSegVolume>", line 2, in ProcessData
  File "C:\PROGRA~1\PYTHON22\lib\site-packages\win32com\client\dynamic.py",
line 240, in _ApplyTypes_
    result = apply(self._oleobj_.InvokeTypes, (dispid, LCID, wFlags,
retType, argTypes) + args)
com_error: (-2147352571, 'Type mismatch.', None, 1)

So, I'm wondering how to hack together a workable collection, or
alternatively how to fool _ApplyTypes_ into passing along the function call
to the COM service.

thanks for any help,
Jess






More information about the Python-list mailing list