win32com and "collection"
Jess Austin (AT)
jesszworg.com
Thu May 29 13:46:48 EDT 2003
"Mark Hammond" <mhammond at skippinet.com.au> wrote :
> >>>>from win32com.server import util
> >>>>from win32com import client
> >>>>col = util.NewCollection([])
> >>>>obj = client.Dispatch('FooServer.BarObject')
> >>>>obj.ProcessData(col, 4)
>
> You will need to "wrap" col - use win32com.server.util.wrap
Thanks for responding Mark. Here is what I get when I try this:
>>> from win32com.server import util
>>> wrap = util.wrap(util.NewCollection([]))
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\PROGRA~1\PYTHON22\lib\site-packages\win32com\server\util.py",
line 20, in wrap
ob = usePolicy(ob)
File "C:\PROGRA~1\PYTHON22\lib\site-packages\win32com\server\policy.py",
line 189, in __init__
self._wrap_(object)
File "C:\PROGRA~1\PYTHON22\lib\site-packages\win32com\server\policy.py",
line 465, in _wrap_
raise error, "Object does not support DesignatedWrapPolicy, as it does
not have either _public_methods_ or _typelib_guid_ attributes."
win32com.server.policy error: Object does not support DesignatedWrapPolicy,
as it does not have either _public_methods_ or _typelib_guid_ attributes.
When I had originally looked at win32com.server.util, I had noticed that
NewCollection() basically just returns a wrapped Collection. It makes sense
that we wouldn't be able to wrap something twice. So unless I'm missing
something, we can expect either util.NewCollection([]) or
util.wrap(util.Collection([])) to give us something we can pass to COM.
Reference my first message for the error that was produced when I attempted
to do that. Does that point to a bug in pythoncom.WrapObject() or maybe
PyIDispatch.InvokeTypes()?
thanks,
Jess
More information about the Python-list
mailing list