本文整理汇总了Python中models.Token.user方法的典型用法代码示例。如果您正苦于以下问题:Python Token.user方法的具体用法?Python Token.user怎么用?Python Token.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Token
的用法示例。
在下文中一共展示了Token.user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: consumer_create
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import user [as 别名]
def consumer_create(request):
if request.method == "POST":
form = ConsumerCreateForm(request.POST)
if form.is_valid():
consumer = Consumer()
consumer.name = form.cleaned_data['name']
consumer.description = form.cleaned_data['description']
consumer.user_id = request.user.username
consumer.refresh_key_secret()
consumer.save()
token = Token()
token.key = Token.generate_token()
token.secret = Token.generate_token()
token.consumer = consumer
token.user = request.user.username
token.type = 'A'
token.save()
return HttpResponseRedirect('/accounts/profile')
else:
form = ConsumerCreateForm()
params = {'form': form}
return render_to_response('oauth/consumer_form.tpl', params,
context_instance=RequestContext(request))
示例2: fe_connect
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import user [as 别名]
def fe_connect(request):
"""
Do the OAuth dance for Fire Eagle!
"""
CONSUMER_KEY = FE_CONSUMER_KEY
CONSUMER_SECRET = FE_CONSUMER_SECRET
CALLBACK_URL = FE_CALLBACK_URL
fe = FireEagle( CONSUMER_KEY, CONSUMER_SECRET )
request_token = fe.request_token( oauth_callback=CALLBACK_URL )
if ( Token.gql( "WHERE user = :1", str(request.user) ).get() != None ):
token = Token.gql( "WHERE user = :1", str(request.user) ).get()
else:
token = Token()
token.user = str(request.user)
token.fe_request_token = str(request_token)
token.put()
auth_url = fe.authorize( request_token, oauth_callback=CALLBACK_URL )
return redirect( auth_url )
示例3: fs_connect
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import user [as 别名]
def fs_connect(request):
"""
OAUTh dance for Foursquare
"""
CONSUMER_KEY = FS_CONSUMER_KEY
CONSUMER_SECRET = FS_CONSUMER_SECRET
CALLBACK_URL = FS_CALLBACK_URL
credentials = foursquare.OAuthCredentials(CONSUMER_KEY, CONSUMER_SECRET)
fs = foursquare.Foursquare(credentials)
request_token = fs.request_token( oauth_callback=CALLBACK_URL )
if ( Token.gql( "WHERE user = :1", str(request.user) ).get() != None ):
token = Token.gql( "WHERE user = :1", str(request.user) ).get()
else:
token = Token()
token.user = str(request.user)
token.fs_request_token = str(request_token)
token.put()
auth_url = fs.authorize( request_token, oauth_callback=CALLBACK_URL )
return redirect( auth_url )