[weboob] [PATCH 1/1] new module openedx

Laurent Bachelier laurent at bachelier.name
Mon Feb 15 15:58:40 CET 2016


On 2016-02-13 11:11, Simon Lipp wrote:
> I would appreciate an advice on how to do properly what I did in an ugly
> way in browser.py:62
> 
> (basically, how to add a specific header (X-Requested-With) only for two
> specific URLs (browser.threads and brower.messages)
> 

I don't think it's especially ugly the way you did it.

There's no way to specify default headers for a page, but you can always
request them explicitly:

browser.location(browser.mypage.build(), headers={'Header-Name':
'Header-Value'})

Note that we also currently have no way to give the extra "headers"
parameter to methods like browser.mypage.go(), as the kwargs are used to
build the URL.

There is probably room for improvement, like having the URL object exert
more control over the PreparedRequest object.


More information about the weboob mailing list