Andrew MacIntyre schrieb:
> Thomas Heller wrote:
> 
>> I would very much like to fix this issue, but I still have to find
>>  one or two COM objects (on my system) that use both 'propput' and
>>  'propputref' for the same property. It would be great if someone 
>> can help me to construct some test cases.
> 
> I know that the ArcGIS COM API has at least one example where a 
> property has both propput and propputref, but to the best of my 
> knowledge its for functionality that I've never needed to use.  I'll
>  see if I can dredge up the specifics.
> 
> My off-the-cuff thought: generate a helper that calls the propputref
>  if the value is a COM pointer, and the propput otherwise.
> 
> I suspect that a fair bit of code that might otherwise need this uses
>  a VARIANT parameter instead and thus avoids the apparent 
> duplication.

Thanks for this suggestion.

I've experimented a bit and am gaining (hopefully) more understanding of this 
issue.

I have hacked up the following:

If both a 'propput' and a 'propputref' for a property named 'Prop' is present, 
comtypes
creates two Python properties:  The first named 'Prop' which uses the COM 
'propget' call
for reading, and the 'propput' call for writing the COM property.
The second I named 'Prop_ref_' which is only writable, and uses the COM 
'propputref' call.

Then I found the 'Scripting.Dictionary' COM object that has all three 
('propget', 'propput',
and 'propputref') so I could experiment a bit.

Then, I located a COM object (of ourself) that has a defaultvalue with dispid 0.

When I assign a COM pointer to this COM object to the dictionary's 'Item', it 
will retrieve
the defaultvalue from the COM pointer and store that.
When I assign a pointer to the dictionaries 'Item_ref_', it will store the COM 
pointer itself.

Fine, so far.  If I understand you correctly, you suggest that setting the 
'Item' property
should automatically determine what should happen:

def _set_Item(self, value):
    if has_default_value_with_dispid_zero(value):
        # use the 'propputref' COM method
    else:
        # use the 'propput' COM method

Is that the semantics that the COM property requires?
Is this what VB does? Or is there a way in VB to select between the two things?

I tried to code up a jscript and vbscript test, but failed.

Thomas


-------------------------------------------------------------------------
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

Reply via email to