logo       

Re: Catching NavigateError in test_browser.py: msg#00026

python.ctypes

Subject: Re: Catching NavigateError in test_browser.py

Thomas Heller <theller@xxxxxxxxxx> writes:

> "Brad Clements" <bkc@xxxxxxxxxxxxx> writes:
>
>> Sorry for the cross-post to ctypes. Venster list seems to be very idle.
>>
>>
>>
>> I'm trying to catch NavigateError events in test_browser.
>>
>> In testing, I added this to the browserWindow class
>>
>> def NavigateError(self, this, pDisp, URL, targetFrameName, statusCode,
>> Cancel):
>>
[...]
>> 2. Cancel is Python type bool, but I'm looking for a POINTER(c_int) as
>> described in ie6_gen
>>
>>
>> DISPMETHOD(0x10f, None, "NavigateError", POINTER(IDispatch),
>> POINTER(VARIANT), POINTER(VARIANT), POINTER(VARIANT), POINTER(c_int)),
>>
>>
>> I need to set Cancel.value = 1
>>
>> How is it that Cancel is being converted to a bool? I how can I set
>> it's value by reference?
>
> The conversion is done in ctypes.com.automation, in the VARIANT class.
> And it seems I got it wrong for the VT_BYREF cases.

I have thought this over, and I think it *is* correct as it currently
is. 'Cancel', the last parameter in the NavigateErorr call, is an
[in,out] parameter in the typelib, while all the other parameters are
simple [in] parameters.

However, *all* parameters are passed as pointers to VARIANTS - even
those marked as [in]. I have no idea why this method signature was
chosen, but we have to live with it.

So, it seems that the conversion to Python objects is correct as it is,
for example the URL parameter should be converted to a Python string,
and not passed as a VARIANT, for example.

The only solution I can see is that ctypes.com should inspect the
typeinformation for this method, to discover that the last parameter is
marked [in, out], and so probably should be passed as a c_int instance,
so that it can be changed.

BTW: I have tried to experiment with pywin32's DispatchWithEvents
implementation, and have not yet been successful in Canceling the
NavigateError event. Does anyone know how to do this?

Thomas



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise