当前位置: 首页>>代码示例>>Python>>正文


Python Member.fb_id方法代码示例

本文整理汇总了Python中models.Member.fb_id方法的典型用法代码示例。如果您正苦于以下问题:Python Member.fb_id方法的具体用法?Python Member.fb_id怎么用?Python Member.fb_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Member的用法示例。


在下文中一共展示了Member.fb_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loggedin

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import fb_id [as 别名]
def loggedin(request,**kwargs):
  
    fp = open( 'tmp.2.log', 'w' )
	
    try:
        request_ids = request.session['fbrequests']
	print >> fp, request_ids
	print >> fp, "====================================="
    except:
        pass
 
    print >> fp, request.method
    print >> fp, request.user.first_name
    print >> fp, request.user.last_name
    print >> fp, request.user.username
    print >> fp, request.user.id
    print >> fp, request.user
 
    print >> fp,'A',[ x for x in UserSocialAuth.objects.filter(user=request.user.id).all()]
    print >> fp,'B',[ x for x in UserSocialAuth.objects.all()]
    print >> fp,'C',[ x for x in UserSocialAuth.objects.filter(provider='facebook',user=request.user.id).order_by('-id')]
    instance = UserSocialAuth.objects.filter(provider='facebook',user=request.user.id).order_by('-id')[0]
    #instance = UserSocialAuth.objects.filter(provider='facebook').get(user=request.user.id).order_by('-id')[0]
    print >> fp, instance
    print >> fp, instance.tokens

    graph   = facebook.GraphAPI(instance.tokens["access_token"])
    profile = graph.get_object("me")
    friends = graph.get_connections("me", "friends")
    print >> fp, profile
    print >> fp, profile['id']
    print >> fp, friends
    fb_id = profile['id']
    request.session['fb_id'] = fb_id

    #graph.put_object("me","apprequests",message="Lup",redirect_uri="http://www.lupalo.com/foo/login/facebook")
    #graph.put_object("me","apprequests",to="100004397774234",message="Lup",redirect_uri="http://www.lupalo.com/foo/login/facebook")

    # TODO check if member exists with the same fb id
    try:
        #m = Member.objects.get(user_name=request.user.id)
        m = Member.objects.get(user_name=request.user.username)
    except Member.DoesNotExist:
        m = None

    if m == None:
        try:
            m = Member.objects.get( fb_id=request.session['fb_id'] )
            m.user_name = request.user.username
            m.save()
        except Member.DoesNotExist:
            m = None
  
    if m == None:
         m       = Member( user_name = request.user.username )
         m.fb_id = request.session['fb_id'] 
         m.save()

    #===== test 
    #   move this to side bar function 
    return render_to_response('requestpage.html')
    #=========



    #return HttpResponseRedirect(reverse('lupalo.views.requestpage'))

    if True:
    #if request.method == 'POST': # If the form has been submitted...
	#form = ContactForm(request.POST) # A form bound to the POST data

	#print >> fp, "validating"
	#print >> fp, form.is_valid()
	#print >> fp, form.errors

	#if form.is_valid():
	if True:
            #user = form.cleaned_data['user']
            #user = request.user.id
            user = request.user.username

	    t        = time.gmtime()
	    name     = time.asctime(t)
	    gamename = time.asctime(t)

            #gamename = form.cleaned_data['room']           
            #newgame  = form.cleaned_data['newgame']           
            newgame  = False        

	    print >> fp, "New Game", newgame

	    if newgame == True:
		Room.objects.all().delete()
	    	r = Room(name=name)
	    	r.save()
	    	Game.objects.all().delete()
	    	g = Game(name=name,room=r)
	    	g.save()
	    	r = Room(name=gamename)
	    	r.save()
#.........这里部分代码省略.........
开发者ID:JanetGuo,项目名称:lupalo,代码行数:103,代码来源:views.old.py


注:本文中的models.Member.fb_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。