Little middleware that create a facebook user

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from facebook import Facebook
from django.db import models
from django.contrib.auth.models import User

class FacebookUser(models.Model):
    user = models.ForeignKey(User, null=True, blank=True)
    uid = models.IntegerField()

    def __unicode__(self):
        return str(uid)

    class Meta:
        pass

    class Admin:
        pass

class FacebookUserMiddleware(object):
    def process_request(self, request):
        if not request.POST.get('fb_sig', None):
            return

        request.facebook.user, new = FacebookUser.objects.get_or_create(uid=int(request.POST.get('fb_sig_user')))

More like this

  1. User post_save signal to auto create 'admin' profile by marinho 4 years, 5 months ago
  2. Template tag to create mailto links with options by celopes 2 years, 11 months ago
  3. EditingMiddleware (quickly open views and templates in your text editor!) by johnboxall 2 years, 11 months ago
  4. Google Closure support in django-compress by fabrice.bonny 2 years, 6 months ago
  5. Mobilize your Django site by stevena0 3 years, 1 month ago

Comments

(Forgotten your password?)