NSManagedHuman / google-api-python-client

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

Dumping and loading oauth2 objects in django fails #300

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
[Use this form for both apiclient and oauth2client issues]

What steps will reproduce the problem?
1. Setup django, using the oauth2 objects
2. run python manage.py dumpdata <project_using_oauth2> > dump.json
3. run python manage.py loaddata dump.json

What is the expected output? What do you see instead?
Expect the fixture to load, but it fails because the objects are not serialized 
correctly

What version of the product are you using? On what operating system?
google-api-python-client 1.0b9, on ubuntu 10.04.

Please provide any additional information below.
The problem can be fixed by adding the following function to 
oauth2client/django_orm.py CredentialsField and FlowField:

  def value_to_string(self, obj):
    value = self._get_val_from_obj(obj)
    return self.get_db_prep_value(value)

This follows the snippet in http://djangosnippets.org/snippets/1694/ which is 
essentially what is being done in django_orm. btw - the snippet comments also 
suggest that the way oauth2client does the database encoding needs to be 
modified to use a deepcopy. I don't know if that is a problem here.

Original issue reported on code.google.com by blaiset...@gmail.com on 2 Sep 2013 at 3:00