tschellenbach / Django-facebook

Facebook open graph api implementation using the Django web framework in python
http://www.mellowmorning.com/
Other
1.43k stars 543 forks source link

Django1.5 + DjCelery + FACEBOOK_CELERY_TOKEN_EXTEND #352

Closed rrix closed 10 years ago

rrix commented 11 years ago

I'm using a custom user model in django 1.5, just started to integrate Celery in to my application, including pulling django-facebook operations in to a queue as well. Anyways, it looks like the logic in the celery module assumes pre-1.5 behavior of a profile to use one to one relationship, and that doesn't fly too well in my application obviously :)

I could monkeypatch this, but it's definitely an issue

[2013-07-06 19:10:31,106: ERROR/MainProcess] Task django_facebook.tasks.extend_access_token[6622e72f-5de4-457a-a595-00c668e08ada] raised exception: AttributeError("'Hugger' object has no attribute 'user'",)
Traceback (most recent call last):
  File "/home/rrix/.virtualenvs/mbrace/lib/python2.7/site-packages/celery/task/trace.py", line 233, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/rrix/.virtualenvs/mbrace/lib/python2.7/site-packages/celery/task/trace.py", line 420, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/rrix/.virtualenvs/mbrace/lib/python2.7/site-packages/django_facebook/tasks.py", line 11, in extend_access_token
    results = profile._extend_access_token(access_token)
  File "/home/rrix/.virtualenvs/mbrace/lib/python2.7/site-packages/django_facebook/models.py", line 213, in _extend_access_token
    token_changed=token_changed, old_token=old_token
  File "/home/rrix/.virtualenvs/mbrace/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 170, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/rrix/.virtualenvs/mbrace/lib/python2.7/site-packages/django_facebook/tasks.py", line 134, in token_extended_connect
    user = profile.user
None: 'Hugger' object has no attribute 'user'

model:

from django.contrib.auth.models import AbstractUser, UserManager
class Hugger(AbstractUser, FacebookProfileModel):
    objects = UserManager()
    zip_code = models.CharField(max_length=5)
    # TODO: Pull GeoDjango in to the mix
    last_location = models.CharField(max_length=100)
    # XXX: Make sure this is US style using https://docs.djangoproject.com/en/1.4/ref/contrib/localflavor/#django.contrib.localflavor.us.models.PhoneNumberField
    phone_number = models.CharField(max_length=20)
tschellenbach commented 11 years ago

Yes this is fairly easy to fix, ill merge contributions which resolve this. Will get around to it myself as well, but that will still take a bit of time.

tschellenbach commented 10 years ago

this is fixed and will be released in 5.2.8 thanks for spotting it!