Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stateful_browser.py: add a response property #369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hemberger
Copy link
Contributor

Whenever we set the browser state, include the request response.
The response property will raise an AttributeError if the state
has not yet been set.

This is not strictly necessary, since we return the request response
in most functions that have one, but it is perhaps a convenience in
some scenarios.

Closes #358.

Whenever we set the browser state, include the request response.
The `response` property will raise an `AttributeError` if the state
has not yet been set.

This is not strictly necessary, since we return the request response
in most functions that have one, but it is perhaps a convenience in
some scenarios.

Closes MechanicalSoup#358.
@hemberger hemberger requested a review from moy May 1, 2021 23:50
@hemberger
Copy link
Contributor Author

One thing that makes me vaguely hesitant about this change is users getting confused about when the response is updated. For example, download_link (for well-motivated reasons) does not update the internal browser state. Therefore,

response = browser.download_link(...)

will not be the same response as

browser.download_link(...)
response = browser.response

The same is already true for the current components of _BrowserState (page, url, and request), but at least for page and url there's a much clearer analogy with a real browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store latest response in the browser state
1 participant