-
Notifications
You must be signed in to change notification settings - Fork 953
Added Google's monkeypatch, disabled caching for now. #383
Conversation
…h library. Disabled caching for now because app engine does not work with the existing strategy.
Hi I actually have never made a pull request so forgive me if this isn't really what I'm supposed to do with it, I just wanted to illustrate how my app engine branch works. Take it or reject it as you will. Discussed in #44. |
Hi! First, thanks for helping make the library better by fixing issues! That is amazing! The failing checks you see above are from the PEP8 based lint check we have, that means that something in the code you added does not pass the PEP8 spec. You can see what they are by running locally Once the |
Wow neat (and strict!) So now we're obviously going to have an import problem with the automated testing because it doesn't know where this crazy requests_toolbelt library is coming from. And also, what's the convention to explain these other things?
Thanks for your warm wishes, I'm happy to dig more into this so if you can help me follow the proper processes along the way. |
I would start by adding a section to the README that says something like "See GAE.md for more details about how to use python-twitter with Google App Engine" -- that will let you go into detail about what is required without making the core README huge. Another thing I would suggest is to not do the imports at the top of the file but instead inside of the api()'s init method so they are only handled if the caller is asking to use GAE -- right now your code fails for me because I'm not using GAE and don't have those modules in my system. A good example of this is the failing tests:
|
…and adapters to init function with an environment check.
Reviewed 2 of 3 files at r3. twitter/api.py, line 181 [r3] (raw file):
You will need to check for the existence of 'SERVER_SOFTWARE' in os.environ also - see the failing tests for the error report Comments from Reviewable |
I made a new virtualenv and everything to try to get the same errors as the tests, I don't know why these things aren't failing for me in the same way. Anyway, I'm still working on it, cool testing suite! |
What's the command that you're using to run the test suite? |
import requests_toolbelt.adapters.appengine # Adapter ensures requests use app engine's urlfetch | ||
requests_toolbelt.adapters.appengine.monkeypatch() | ||
cache = None # App Engine does not like this caching strategy, disable caching | ||
if 'Google App Engine' in os.environ.get('SERVER_SOFTWARE', None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.environ.get
will return a string, so you'll want to check via something like:
if os.environ.get('SERVER_SOFTWARE', None) == 'Google App Engine':
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case the value for SERVER_SOFTWARE is actually different depending on the version. Ie. ' 'Google App Engine/3.25' or whatever it might be, so I can't check the whole string.
Current coverage is 69.00% (diff: 50.00%)@@ master #383 diff @@
==========================================
Files 8 8
Lines 2014 2020 +6
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 1391 1394 +3
- Misses 623 626 +3
Partials 0 0
|
I realise this has been a bit of a train wreck so far, but I've been learning a lot so thank you for following along. |
Reviewed 1 of 1 files at r5. Comments from Reviewable |
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. Comments from Reviewable |
Reviewed 1 of 1 files at r5. Comments from Reviewable |
it's both exciting and scary to submit a code change to someone-else's project so I'm glad you have and also glad you are letting us point the tweaks needed! |
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. twitter/api.py, line 181 [r3] (raw file):
|
Once we let Jeremy look over the changes and he +1's them we can then merge \o/ |
Reviewed 2 of 3 files at r3, 1 of 1 files at r5. Comments from Reviewable |
With the caveat that I'm not super familiar with Google App Engine, everything looks good to me! Thanks! |
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. Comments from Reviewable |
I should also mention that I am using this latest version on my Google App Engine project and it's working as expected. |
\o/ Thanks for the improvements! |
Does anyone have any objection to me moving GAE.rst into the docs folder? It's not getting picked up on readthedocs.io if it's in the root dir :( |
Added Google's monkeypatch so requests will use the appengine urlfetch library. Disabled caching for now because app engine does not work with the existing strategy.
This change is