[PyQt] Monkeypatching QWebPage.userAgentForUrl

Kay Hayen kayhayen at gmx.de
Fri May 13 02:23:30 BST 2011



Hello everybody,

>> Somehow it seems, that the my patched method is never called.
>>
>> What could be the reason?
>>
>> thanks in advance for any explanations or suggestions how to change the
>> user agent 'globally'
>
> Why do you try to monkeypatch it? Subclassing QWebView and implementing just
> the overridden method is much cleaner and doesn't look like a hack.

Also if you my message about the SIP issue, it appears that the PyQt 
core will not consider any overload it doesn't detect as being such at 
class creation time.

I almost clearly doubt, that attribute assignment will modify the class 
later on.

In general, it appears, that to overload you must use a class and for me 
unfortunately, it must be a pure Python function or method object at 
that point.

Enhancing sip to be able to track at run time the changes to the class 
appears possible. For consistency with Python it should be done, but the 
benefit, other than consistency with every other Python class, I admit, 
is dubious.

Yours,
Kay


More information about the PyQt mailing list