RudySantana / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
0 stars 0 forks source link

Library crashes when null=True not present in Model definitions (Django) #161

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a Django project, use the Django sample as a basis 
2. Use Google Calendar as scope and try to authenticate (by going to the 
appropriate URL)

What is the expected output? What do you see instead?
The expected output is a Django HttpResponse, either a template or just a 
response with some useful information. For debugging, I used 'return 
HttpResponse("Authenticated")'. And on the line above that, I had 'print 
dir(service)' to see that it has authenticated and the services are available 
(printed to stdout by Django's runserver).
The result instead is an EOFError and the Django built-in runserver 
occasionally (not always..) shows a broken pipe trace. The authentication 
process is cut short, no auth occurs.

What version of the product are you using? On what operating system?
I am using oauth2client version 1.0c2, Python 2.7.3, Django 1.4 on Arch Linux 
(3.4.4-2).

Please provide any additional information below.
After hours of battling, I finally figured out that unless you have
credential = CredentialsField(null=True) in your models.py in CredentialsModel, 
the above-mentioned behaviour occurs. I am not entirely sure as to why this 
fixes it (can anyone shed some light, please?), but I think that in the Django 
sample project, the credential object is initally None, however, this cannot be 
stored, because CredentialsField is defined to only accept not null values. And 
then this strange behaviour occurs.
Perhaps it's worth making the CredentialField null by default?

Original issue reported on code.google.com by karlviis...@gmail.com on 6 Jul 2012 at 6:29

GoogleCodeExporter commented 8 years ago
Issue 167 has been merged into this issue.

Original comment by jcgregorio@google.com on 24 Jul 2012 at 9:26

GoogleCodeExporter commented 8 years ago
I have patched django_orm.py with a constructor to the CredentialsField class 
that sets null=True by default.
I have tested it using a modified version of the example Django project 
(http://code.google.com/p/google-api-python-client/source/browse/#hg%2Fsamples%2
Fdjango_sample) and authenticating against Google Calendar.
Could someone review it and maybe provide feedback?

Original comment by karlviis...@gmail.com on 27 Jul 2012 at 9:32

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks! Here are the instructions for contributing patches:

  http://code.google.com/p/google-api-python-client/wiki/BecomingAContributor

Original comment by jcgregorio@google.com on 27 Jul 2012 at 1:39

GoogleCodeExporter commented 8 years ago
This issue was closed by revision e022f6ac1d70.

Original comment by jcgregorio@google.com on 1 Aug 2012 at 6:23

GoogleCodeExporter commented 8 years ago
Issue 166 has been merged into this issue.

Original comment by jcgregorio@google.com on 1 Aug 2012 at 6:32

GoogleCodeExporter commented 8 years ago
Issue 173 has been merged into this issue.

Original comment by jcgregorio@google.com on 9 Aug 2012 at 12:57