本文整理汇总了Python中models.Token.all方法的典型用法代码示例。如果您正苦于以下问题:Python Token.all方法的具体用法?Python Token.all怎么用?Python Token.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Token
的用法示例。
在下文中一共展示了Token.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lookup_token
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import all [as 别名]
def lookup_token(self, token_type, token):
if token_type == 'request':
token_type = Token.REQUEST
elif token_type == 'access':
token_type = Token.ACCESS
logger.warning("!!! In GAEOAuthDataStore.lookup_token key_:%s, token_type: %s"%(token,token_type))
request_tokens = Token.all()\
.filter('key_ =',token)\
.filter('token_type =',token_type).fetch(1000)
if len(request_tokens) == 1:
self.request_token = request_tokens[0]
return self.request_token
elif len(request_tokens) == 0:
return None
else:
raise Exception('More then one %s token matches token "%s"'%(token_type,token))
示例2: sync
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import all [as 别名]
def sync(request):
"""
It's the cron job that gets run every 2 minutes (or on request). Iterates over users and
queues tasks to sync. Will only 'iterate' over the current user
if called by a logged in user.
"""
tokens = []
if (request.user.is_anonymous()):
tokens = Token.all().fetch(1000)
else:
tokens.append(Token.gql( "WHERE user = :1", str(request.user) ).get())
for t in tokens:
taskqueue.add(url='/syncworker/?user=%s' % str(t.user), method='GET')
"""
We cannot return a redirect when called anonymously as a cron job.
Google App Engine will complain about 'Too many continues.'
"""
if (request.user.is_anonymous()):
return render_to_response('firecheckin/index.html')
else:
return redirect( "/" )