-
Notifications
You must be signed in to change notification settings - Fork 430
"to_python" function not working in class CredentialsField with python3 #168
Comments
I just had the same issue, but when applying your solution I now get "Incorrect padding" when calling len(entities) inside the function locked_get inside oauth2client.django_orm. Did you had the same problem? |
I am sorry, I don't have the same problem. |
Just encountered this under Python 3.4.3 on Django 1.8.2. Is there a fix in the works for this? |
I couldn't make it work. |
Here's the explanation of issue: https://docs.djangoproject.com/en/1.7/howto/custom-model-fields/#the-subfieldbase-metaclass
from django.utils.six import with_metaclass
class HandField(with_metaclass(models.SubfieldBase, models.Field)):
... To fix this you should modify django_orm.py file according this explanation. |
I confirm vooft's fix works. However, you have to modify the oauth2client/django_orm.py source. |
@Arlus would you share your django_orm.py source please? I modified like this and now I have incorrect padding error. from django.utils.six import with_metaclass
class CredentialsField(with_metaclass(models.SubfieldBase, models.Field)):
def __init__(self, *args, **kwargs): |
[WARNING IMPORTANT] Une modification est obligatoire dans la bibliothèque "oauth2client/django_orm.py": Ligne 30 et 55 il faut adapter pour python 3 les lignes : FROM: class CredentialsField(models.Field): __metaclass__ = models.SubfieldBase TO (python3): class CredentialsField(models.Field, metaclass=models.SubfieldBase): # __metaclass__ = models.SubfieldBase + Protocole de connection OAuth fonctionnel + Liaison à un compte youtube pour un seul utilisateur : spamadmin + Mise en place de messages d'erreurs detaillés pour chaque cas et selon admin/notadmin
My solution for python3, django 1.8 with postgres database: There is a missing step right before saving the byte data to database, and after retrieving the data back from database: The byte data need to be converted to/from string first. You can convert byte to string and vice versa with You also do not need the
|
Fixed in #316. Please re-open if this is still broken. |
I am a newbie with python.
Recently I was trying to build a small web app with Google API in Django and Python 3.4.
And I use the storage utilities from oauth2client.django_orm
The storage.put() function work fine but when I use the storage.get() function, it just give me a string but not a credentials object.
After testing and reading the source code of oauth2client.django_orm.
I found the problem was the "to_python" function doesn't work and just return the Base64 data back.
Finally I found the cause from the internet: "In python 3 the module-global __ metaclass__ variable is no longer supported."
And it has to change like this to work in Python 3
The text was updated successfully, but these errors were encountered: