moneyapi / google-api-python-client

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

TypeError: cannot concatenate 'str' and 'NoneType' objects #267

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using StorageByKeyName to store credentials obtained through 
oauth_flow.step2_exchange(code) after a G+ sigin process (following the 
approach in 
https://developers.google.com/api-client-library/python/platforms/google_app_eng
ine#Credentials)

However, the line storage.put(credentials) raises the following error:

  File "/Users/antonio/devel/theapp/code/handlers/connect_handler.py", line 137, in _save_token
    storage.put(credentials)
  File "/Users/antonio/devel/theapp/vendor/oauth2client/client.py", line 325, in put
    self.locked_put(credentials)
  File "/Users/antonio/devel/theapp/vendor/oauth2client/appengine.py", line 458, in locked_put
    setattr(entity, self._property_name, credentials)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 615, in __set__
    setattr(model_instance, self._attr_name(), value)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 752, in _attr_name
    return '_' + self.name

What steps will reproduce the problem?
1. Obtain a credentials object
2. Create storage = StorageByKeyName(CredentialsModel, gplus_id, 'credentials')
3. Try saving it: storage.put(credentials)

What is the expected output? What do you see instead?

Credentials saved with no issues.

What version of the product are you using? On what operating system?

Latest version of the library - google-api-python-client-gae-1.1.zip

Please provide any additional information below.

I dug up the actual method in __init__.py, notice the comment:

def _attr_name(self):
    """Attribute name we use for this property in model instances.

    DO NOT USE THIS METHOD.
    """

    return '_' + self.name

Original issue reported on code.google.com by azugal...@gmail.com on 7 May 2013 at 8:20

GoogleCodeExporter commented 8 years ago
I can't duplicate this error, closing for now, but reopen if you can post code 
that duplicates the issue.

Original comment by jcgregorio@google.com on 13 May 2013 at 3:09

GoogleCodeExporter commented 8 years ago
For anyone else who stumbles across this problem I just had the same issue and 
then by looking at the source code for oauth2client I found that I needed to be 
using CredentialsNDBProperty instead of CredentialsProperty because I was using 
the NDB datastore.

It would be nice if the docs mentioned this as well. From the docs it sounds 
like CredentialsProperty detects whether it's a NDB model or not.

Original comment by arto...@gmail.com on 30 Jul 2014 at 4:10

GoogleCodeExporter commented 8 years ago
This sounds plausible, I might have used a CredentialsProperty while my models 
always are NDB based.

Original comment by azugal...@gmail.com on 12 Aug 2014 at 4:32