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

Create new Session method prepare_redirected_request. #1965

Closed
wants to merge 1 commit into from

Conversation

zackw
Copy link
Contributor

@zackw zackw commented Mar 16, 2014

This is almost entirely moving code around: the new method is
most of the code that used to be the loop body of resolve_redirects.

This is almost entirely moving code around: the new method is
most of the code that used to be the loop body of `resolve_redirects`.
@Lukasa
Copy link
Member

Lukasa commented Mar 16, 2014

Why are we removing the redirect mixin?

@zackw
Copy link
Contributor Author

zackw commented Mar 16, 2014

It becomes obvious when you break up resolve_redirects this way that both halves rely on internal Session data and therefore ought to be Session methods.

TBH I don't really understand why the mixin existed in the first place - it's not providing a useful conceptual division nor could it realistically have been applied to any other class but Session.

@zackw
Copy link
Contributor Author

zackw commented Mar 16, 2014

(To be scrupulously accurate: the remaining use of internal Session data inside resolve_redirects is unnecessary - it duplicates something send does already. I was keeping this pull strictly to code motion so I left it there. Even so, though, the conceptual argument stands.)

@sigmavirus24
Copy link
Contributor

TBH I don't really understand why the mixin existed in the first place

Testability (as was shown with #1963). Frankly, other parts of a Session would be easier to test if they were mix-ins as well (specifically the cookie handling pieces of logic). Then again, most people don't care how testable their code is.

nor could it realistically have been applied to any other class but Session

That's not exactly right. Most people would not have wanted to apply it to any other class but Session, but it very realistically could have been applied to any other class that was carefully constructed (again, shown in #1963).

@Lukasa
Copy link
Member

Lukasa commented Mar 16, 2014

I also disagree with your argument that it doesn't provide a good conceptual division, and I think this change emphasises the conceptual division, not weakens it. Redirection is complicated, and the number of methods that handle redirection is increasing all the time. The mixin provides an organisational framework for that code which makes the code easier to follow (IMO). The fact that you've added more methods here makes that even clearer.

Yes, the mixin is tightly coupled to the Session class, but that's ok: it's an organisational and conceptual distinction not a philosophical one.

@kennethreitz
Copy link
Contributor

Exactly what @Lukasa said — the Mixin is all about readability :)

@kennethreitz
Copy link
Contributor

Closing due to inactivity.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants