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


Python Room.fb_request_id方法代码示例

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


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

示例1: handlefbrequestcallback

# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import fb_request_id [as 别名]
def handlefbrequestcallback(request):
    fp = open( 'tmp.3.log', 'w' ) 
    print >> fp, request
    request_str   = ( request.GET.get('request') )
    request_to    = ( request.GET.get('to') )
    #request_from  = ( request.GET.get('from') )
    request_id    = ( request.GET.get('id') )
    request_from  = request.session['fb_id']
 
    #if request_to:
    #   request_to = int(request_to.encode('ascii'))

    #if request_from:
    #   request_from = int(request_from.encode('ascii'))

    #if request_id:
    #   request_id = int(request_id.encode('ascii'))

    print >> fp, "request id", request_id
    print >> fp, "request string", request_str
    print >> fp, "request to", request_to
    print >> fp, "request from", request_from
    print >> fp, "request fb id", request.session['fb_id']

    try:
    	m_to   = Member.objects.get(fb_id=request_to)
    except: 
	# need to make member    	
        m_to   = Member(fb_id=request_to)
  
    try: 
        m_from = Member.objects.get(fb_id=request_from)
    except:
	# need to make member    	
        m_from = Member(fb_id=request_from)

    # name is set
    gamename = "%s_%s_%s" % ( request_from, request_to, time.asctime(time.gmtime()) ) 
    r = Room(name=gamename)
    r.fb_request_id = request_id
    r.save()

    g = Game(room=r)
    # game name and room name duplicated 
    g.name = gamename
    g.save()

    p = Player(game=g,turn=0)
    p.member = m_from
    p.save()

    # TODO assumes two player game - generalize
    p = Player(game=g,turn=1)
    p.member = m_to
    p.save()

    #return HttpResponseRedirect('requestpage.html')
    return HttpResponseRedirect( reverse('lupalo.views.lupalo') ) # Redirect after POST
开发者ID:JanetGuo,项目名称:lupalo,代码行数:60,代码来源:views.old.py

示例2: makerobogame

# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import fb_request_id [as 别名]
def makerobogame(request):
  
    fb_id = ROBOT1
    request.session['fb_id'] = fb_id
 
    # make robot player 1
    try:
        m_from = Member.objects.get( fb_id=ROBOT1 )
    except Member.DoesNotExist:
        m_from   = Member(fb_id=ROBOT1)
        m_from.user_name     =  'Robo1'
        m_from.fb_first_name =  'Robo1'
        m_from.fb_last_name  =  'Robo1'
        m_from.save()
    # make robot player 2
    try:
        m_to = Member.objects.get( fb_id=ROBOT2 )
    except Member.DoesNotExist:
        m_to   = Member(fb_id=ROBOT2)
        m_to.user_name     =  'Robo2'
        m_to.fb_first_name =  'Robo2'
        m_to.fb_last_name  =  'Robo2'
        m_to.save()

    # name is set
    request_from = 'Robo1'
    request_to   = 'Robo2'
    gamename = "%s_%s_%s" % ( request_from, request_to, time.asctime(time.gmtime()) ) 
    r = Room(name=gamename)
    r.fb_request_id = ROBOREQUEST
    r.save()

    g = Game(room=r)
    # game name and room name duplicated 
    g.name = gamename
    g.save()

    p = Player(member=m_from)  # player in game, link to member 
    p.game=g		       # game 
    p.turn=0                   # static order of player in game
    p.save()

    request.session['player_id'] = p.turn

    # TODO assumes two player game - generalize
    p = Player( member = m_to )
    p.game=g
    p.turn=1
    p.save()

    return HttpResponse( simplejson.dumps( { "gamename": gamename } ), mimetype='application/javascript' )
开发者ID:cliffmeyer,项目名称:lupalo,代码行数:53,代码来源:views.py

示例3: handlefbrequestcallback

# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import fb_request_id [as 别名]
def handlefbrequestcallback(request):
    fp = open( 'tmp.3.log', 'w' ) 
    print >> fp, request
    request_str   = ( request.GET.get('request') )
    request_to    = ( request.GET.get('to') )
    request_id    = ( request.GET.get('id') )
    request_from  = request.session['fb_id']

    print >> fp, "request id",     request_id
    print >> fp, "request string", request_str
    print >> fp, "request to",     request_to
    print >> fp, "request from",   request_from
    print >> fp, "request fb id",  request.session['fb_id']

    instance = UserSocialAuth.objects.filter(provider='facebook',user=request.user.id).order_by('-id')[0]
    graph   = facebook.GraphAPI(instance.tokens["access_token"])

    try:
        profile = graph.get_object("me")
    except:
        logout(request)
        return HttpResponseRedirect( reverse('lupalo.views.lupalo') ) # Redirect after POST

    try:
    	m_to   = Member.objects.get(fb_id=request_to)
    except: 
	# need to make member    	
        m_to   = Member(fb_id=request_to)

        # play against robot
        if request_to == 'auto':
            m_to.fb_first_name = 'auto'
            m_to.fb_last_name  = 'auto'
	else: 
            profile = graph.get_object( str(request_to) )
            m_to.fb_first_name = profile['first_name']
            m_to.fb_last_name  = profile['last_name']
        m_to.save()

    if m_to.fb_first_name == None or m_to.fb_last_name == None:
        profile = graph.get_object( str(request_to) )
        m_to.fb_first_name = profile['first_name']
        m_to.fb_last_name  = profile['last_name']
        m_to.save()
  
    try: 
        m_from = Member.objects.get(fb_id=request_from)
    except:
	# need to make member    	
        m_from = Member(fb_id=request_from)
        profile = graph.get_object( str(request_from) )
        m_from.fb_first_name = profile['first_name']
        m_from.fb_last_name  = profile['last_name']
        m_from.save() 

    if m_from.fb_first_name == None or m_from.fb_last_name == None:
        profile = graph.get_object( str(request_from) )
        m_from.fb_first_name = profile['first_name']
        m_from.fb_last_name  = profile['last_name']
        m_from.save()

    # name is set
    gamename = "%s_%s_%s" % ( request_from, request_to, time.asctime(time.gmtime()) ) 
    print >> fp, "gamename", gamename
    r = Room(name=gamename)
    r.fb_request_id = request_id
    r.save()

    g = Game(room=r)
    # game name and room name duplicated 
    g.name = gamename
    g.save()

    p = Player(member=m_from)
    p.game=g
    p.turn=0
    p.save()

    # TODO assumes two player game - generalize
    p = Player( member = m_to )
    p.game=g
    p.turn=1
    p.save()

    #return HttpResponseRedirect('requestpage.html')
    return HttpResponseRedirect( reverse('lupalo.views.lupalo') ) # Redirect after POST
开发者ID:cliffmeyer,项目名称:lupalo,代码行数:88,代码来源:views.py


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