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

2879 requests cleanup #2894

Merged
merged 4 commits into from
Jan 22, 2020
Merged

Conversation

tfmorris
Copy link
Contributor

Closes #2879

Removes unnecessary urlencode() calls and fixes up the import for the remaining one that's needed.

Stakeholders

@cdrini for vendors.py @tabshaikh for the others - as mentioned in the issue, I think this is your code, so please review.
@mekarpeles

Copy link
Collaborator

@hornc hornc left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@mekarpeles , could you take a quick look at the sponsorship code changes and make sure you are happy with them? I know you are working on this area at the moment.

If this doesn't conflict with any current in-flight work, I am happy to merge this ASAP.

openlibrary/core/vendors.py Show resolved Hide resolved
openlibrary/tests/core/test_sponsors.py Show resolved Hide resolved
The switch to Requests was only partially done without any error
handling. This switches the error handling to use Requests too.
For the remaining one that's needed import using six so that
it's compatible with both Python 2 and 3.
@tfmorris
Copy link
Contributor Author

Rebased to address merge conflict. Please force refresh any checked out branches.

@hornc hornc added the On Dev label Jan 22, 2020
@hornc
Copy link
Collaborator

hornc commented Jan 22, 2020

@cdrini I have put this of dev.openlibrary.org for testing

@hornc hornc merged commit f2b94f1 into internetarchive:master Jan 22, 2020
@@ -50,7 +49,7 @@ def get_sponsorships_by_contact_id(contact_id, isbn=None):
data['json'] = json.dumps(data['json']) # flatten the json field as a string
r = requests.get(
lending.config_ia_civicrm_api.get('url', ''),
params=urllib.urlencode(data),
params=data,
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned about removing the urllib.urleencode here, I feel like titles w/ encodings and other cases necessitated this addition and I get the feeling this is going to break things.

Copy link
Collaborator

@cclauss cclauss Jan 23, 2020

Choose a reason for hiding this comment

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

The Python Docs recommend the use of the Requests module over the Standard Library because it has a much cleaner API and because in handles Unicode issues so much better. On both Python 2 and Python 3 Requests favours Unicode over bytes/str and its convince functions just work without the struggles that the Standard Library imposes.

@tfmorris tfmorris deleted the 2879-requests-cleanup branch August 13, 2020 05:49
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.

Don't mix urllib with Requests
5 participants