-
Notifications
You must be signed in to change notification settings - Fork 430
Add Django Util With Decorator and Views #332
Conversation
sys.modules['django_settings'] = django_settings = imp.new_module( | ||
'django_settings') | ||
django_settings.SECRET_KEY = 'xyzzy' | ||
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_django_settings' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
All new files added should have 100% coverage (towards #212). From: The following have less than 100%:
|
Running
|
If running the tests create |
0ff07d0
to
416a548
Compare
@dhermes thanks for taking a look, I now I have 100% coverage on all the main files and fixe the gitignore. The test file is still missing 3 lines, I added #pragma: no cover, since they are test views and the point is that the decorator redirects before they are run. I could maybe mock them but I think it's clearer to have them as functions with the decorator...but for some reason coverage isn't respecting the pragma. Investigating why... |
Check out |
Wow, thanks for the headsup on the pragma case sensitivity, it was really confusing me, forgot to check all the hidden files! Ok, now I should have 100% test coverage. I also added NO COVER to apps.py as well, it's covered in 2.7+ but it skips the code in 2.6, and since the 2.6 case isn't run by coverage the 'else' branch isn't covered. It's basically just a metadata class for recent Django versions, which dropped support for 2.6 and so the version of Django tox installs for 2.6 doesn't have the imports. So I think this is ready for further review or merge whenever you or nathaniel find the time. jonparrot already did a review. |
Summoning @anthmgoogle, he should give this a review as well. |
Sorry, I don't plan on reviewing (not enough cycles). I was just "protecting" my work towards #212 by making sure big changes were fully tested. I actually took a stab at testing |
I am able to review this but it would be best if I were last. Poke me after both @jonparrott and @anthmgoogle are satisfied? |
@dhermes Will do, thanks for the help. I planned to do that in a separate PR as part of Storage improvement efforts but I could add it onto this one. Also curious if it would make sense to move django_orm into this package or if that's not ok since it breaks existing code (I'm guessing it's ok since this library has releases). @nathanielmanistaatgoogle sounds good to me, @jonparrott already took a look (and it's a lot of extremely similar code to his own) but I'll hold off for @anthmgoogle and ping you after. |
I'm satisfied in terms of overall approach, parity with |
@waprin You should do it in a separate PR. The smaller a PR is, the easier it is on everyone. As for moving |
|
||
|
||
@required | ||
def requires_default_scopes(request): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Finished a review pass. I suggested one follow up feature that could be done at a later time. Some minor suggestions about error messages, but consider this a LGTM from me. Looking great. Really exciting to see this functionality. |
1f37b2e
to
822754c
Compare
@anthmgoogle Thanks for review, sorry for delay in turnaround. Let me know if you can +1 now and I can pass it along to Nathaniel. I agree that missing the optional oauth was a major oversight so I added it. Now there are two decorators Also based on your comments, I also improved the error messages in the oauth2callback, and reference the Github issue for the pluggable storage feature in the TODO. That is next up on our radar along with some other refactoring. |
LGTM. |
@nathanielmanistaatgoogle ready for your pass when you have a chance. |
I am oversubscribed for the next few weeks but happy to accommodate if necessary; how time-sensitive is this? |
I suppose that's up to @anthmgoogle. I don't want to start on #326, #319, and #225 until this is in, but those are rather long-tail issues. |
@nathanielmanistaatgoogle It's the season of giving, perhaps you are ready to give this another pass. I know you are tied up in storage PR atm, just your weekly friendly ping this is still here. |
Thank you for your patience; I am finally getting to this in the next hour. I apologize if this is slow to swap back into my working memory and I ask the same questions I asked last month. |
settings_instance.GOOGLE_OAUTH2_CLIENT_SECRET | ||
else: | ||
raise exceptions.ImproperlyConfigured( | ||
"Must specify either GOOGLE_OAUTH2_CLIENT_SECRETS_JSON,or both " |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I'm somewhat bothered by the structure of this - rather than a new package with a non-empty |
Not sure exactly what you mean by package-private helper modules - I am guessing you mean everything that is part of the public API goes in oauth2client/django_util.py and everything else goes into a helper module or two? I originally did this PR as one file, and it wouldn't be too much work to go back. Django doesn't really force you in any technical sense. However, I laid it out the way I did so it mirrors other Django apps/extensions I looked at: From the Django project:: In the wild: So it's a choice between being closer to Django style or other extensions in this library (like Flask). @jonparrott suggested I make it closer to Django which made sense to me. Also, keep in mind we are probably going to move this to a contrib package anyway, #326, which also tilts my opinion towards keeping closer to Django style. But, ultimately I'm not super committed to one way or the other, and if you have something else in mind, I'm fine to change it to whatever you'd like. |
Yeah, I'm now persuaded that the way this is laid out is just fine. What's with the failing test result? Does this need to wait for anything else to go in before it can be merged? |
Fix the broken RST in the docstring
|
cd65d81
to
3267326
Compare
@nathanielmanistaatgoogle had to rebase, ready to merge when you are. |
@@ -46,12 +47,15 @@ deps = {[testenv]deps} | |||
basepython = | |||
python2.6 | |||
commands = | |||
nosetests \ | |||
nosetests \ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Now that the |
Yes, if you've rebased, @waprin, might as well go ahead and move it. Otherwise I can just move it when I move everything else. |
Ok I'll move it now |
b78d339
to
6813b78
Compare
Adds a submodule that provides views, decorator, and signals to help a Django web application complete OAuth2 authorization.
Ok, moved to contrib and I did some double manual checking so I think it's good to go. @nathanielmanistaatgoogle |
Django Util With Decorator and Views.
Yay! |
Great to see this feature. Thanks all. |
This Django extension adds the views, decorators, and signals to oauth2client.
This is heavily based on the work @jonparrott did for oauth2client/flask_util.
Currently the only storage offered uses Django sessions. Based on issue #319 more storage options are planned along with integration to the existing CredentialsField in django_orm.
This adds an environment variable to the tox script. This might not be strictly necessary, but it did simplify the tests a lot, since Django settings get looked up at import time and cached so it's easiest if they have an environment variable pointing to an existing settings module when the tests are started.
This could have been squeezed into a single file, but I spilt it into separate files based on existing Django extension conventions.