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')))