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

Tidying up a bit for requests 1.0 #4

Merged
merged 2 commits into from Dec 19, 2012

Conversation

ib-lundgren
Copy link
Member

I've added some initial tests and cleaned up the extension code a bit.

Unfortunately this code depends heavily on an update to requests.models.py in which lines 200 & 201 are swapped, i.e.

    p.prepare_auth(self.auth)
    p.prepare_body(self.data, self.files)

becomes

    p.prepare_body(self.data, self.files)
    p.prepare_auth(self.auth)

Why? Because we have no idea in auth whether body will soon be filled with files data or not and consequently it would be foolish to assume form encoded on empty body.

I've not had time to look into what implications this might have for requests. Will send a PR when I have. @kennethreitz

@gammasts
Copy link

You left some print statements in there: print 'aaaaT', r.body and print 'WOOOT', r.body. Was eager to get these changes into my local since 1.0 broke a few things regarding oauth and POST requests.

@Lukasa
Copy link
Member

Lukasa commented Dec 18, 2012

I'm just letting you know that I saw this. I don't have time to get to it this evening, but didn't want you to think it had fallen off my radar. =)

@ib-lundgren
Copy link
Member Author

No worries, just threw this together quickly in cause many were affected. Would have updated this earlier but since I don't have much time for open source atm I tunnelvision on oauthlib and am completely oblivious to where it is actually used :)

r.url, r.headers, r.data = self.client.sign(
unicode(r.full_url), unicode(r.method), r.data, r.headers)
unicode(r.url), unicode(r.method), r.body or '', r.headers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r.body or '' should probably read r.body or None.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an artifact from when I refactored the code, if its r.body, '' or None does not matter at all in this case. Unless I did think of something clever which I've now forgotten...

@Lukasa
Copy link
Member

Lukasa commented Dec 19, 2012

Makes sense to me. @kennethreitz, when/if you get time, can you take a look at this too?

@kennethreitz
Copy link

Seems fine to me.

@ib-lundgren
Copy link
Member Author

It still requires the swapping in requests tho, don't see a good way around that unless more data is sent into the auth or if the content-type header is populated earlier.

@Lukasa
Copy link
Member

Lukasa commented Dec 19, 2012

Good point. Want to create a PR on Requests for that change?

@kennethreitz
Copy link

I'll be happy to make that change. I didn't put much thought into the order.

@kennethreitz
Copy link

Send a PR :)

@ib-lundgren
Copy link
Member Author

Hehe, sure.

@ib-lundgren
Copy link
Member Author

You can probably go ahead and merge this even if the PR is not in requests yet since the current code does not work at all =)

kennethreitz pushed a commit that referenced this pull request Dec 19, 2012
Tidying up a bit for requests 1.0
@kennethreitz kennethreitz merged commit b079d2b into requests:master Dec 19, 2012
@michaelhelmick
Copy link

@ib-lundgren was there ever a PR that got merged into requests? I had the chance to update requests_oauthlib to 0.2.0 and requests to 1.0.4 and still get the same error I did in #1

@ib-lundgren
Copy link
Member Author

Yepp, it is merged and in at least 1.0.4. However the changes you need are not included in requests_oauthlib 0.2.0.

I never tried running the code mentioned in #1 but my flask test example ran fine

https://gist.github.com/4487236

@michaelhelmick
Copy link

Oh, alright. Yeah, cause I was going to say that it didn't fix my problem. :( haha

Mike Helmick

On Tuesday, January 8, 2013 at 2:47 PM, Ib Lundgren wrote:

Yepp, it is merged and in at least 1.0.4. However the changes you need are not included in requests_oauthlib 0.2.0.
I never tried running the code mentioned in #1 (#1) but my flask test example ran fine
https://gist.github.com/4487236


Reply to this email directly or view it on GitHub (#4 (comment)).

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.

None yet

5 participants