Hi Thomas,
I noticed your new comtypes 0.4 release from Friday, which includes not only my
patch, but a complete revamping of the safearray implementation. Thank you! I'm
going to try it next week. With this new safearray support, I can likely get a
particular COM piece of my system to work without requiring C++ or C#.
In the meantime, I noticed something that I believe is a bug with how COM
properties are mapped to object attributes... If you run the following code, it
should display the problem:
import comtypes, comtypes.client
xl=comtypes.client.CreateObject('Excel.Application')
xl.Visible=1 # (1)
xl.Workbooks.Add()
r=xl.Range['A1:B1']
r.Value # (2)
r.Value() # (3)
r.Value=1 # (4)
Basically, this is equivalent to code in the Excel test case:
http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_excel.py
Incidentally, the test case fails on my system. Perhaps it runs fine on yours.
Line (1) displays how properties should work, and it does work for me.
Assigning to Python object attribute, updates the corresponding COM property.
Line (2) should read the contents of the range of cells. But, it doesn't.
Instead, I get an instance of a bound_named_property. Line (3) works, by
calling the getter. But, why is it mapped this way? I think it's inconsistent,
and I prefer behaviour (1) to (3). Furthermore, the assignment in line (4)
simply overwrites the attribute, and has no COM effect.
Apparently, all this happens in
comtypes._cominterface_meta._make_dispmethods(). I don't entirely understand
all the cases that you are handling, and what you have in mind, so I don't know
how to best fix it.
Thank you for writing comtypes. I use ctypes all the time, and I think comtypes
is taking exactly the right approach to Python-COM binding.
All the best,
Rimon.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users