本文整理汇总了Python中models.Session.all方法的典型用法代码示例。如果您正苦于以下问题:Python Session.all方法的具体用法?Python Session.all怎么用?Python Session.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Session
的用法示例。
在下文中一共展示了Session.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import all [as 别名]
def get(wave_id, wavelet_id, email):
"""
Uses memcache or the datastore to fetch a single session by wave_id,
wavelet_id and email
@param wave_id: the id of the session to fetch
@param wavelet_id: the id of the session to fetch
@param email: the email of the session to fetch
@return the session using the most efficient means possible or None if it
couldn't be found
"""
key = base64.b64encode(memcacheConfig.PREFIX["SESSION"] + wave_id + wavelet_id + email)
session = memcache.get(key)
if not session == None:
dbmigration.migratev1tov2([session])
return session
else:
query = Session.all()
query.filter("wave_id =", wave_id)
query.filter("wavelet_id =", wavelet_id)
query.filter("email =", email)
session = query.get()
dbmigration.migratev1tov2([session])
memcache.add(key, session, time=memcacheConfig.DEFAULT_EXPIRE_SECS)
return session
示例2: fetch
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import all [as 别名]
def fetch(wave_id, wavelet_id):
"""
Uses memcache or the datastore to get fetch sessions by wave_id and
wavelet_id
@param wave_id: the id of the session to fetch
@param wavelet_id: the if of the session to fetch
@return the sessions using the most efficient means possible or None if it
couldn't be found
"""
key = base64.b64encode(memcacheConfig.PREFIX["SESSION"] + wave_id + wavelet_id)
sessions = memcache.get(key)
if not sessions == None:
dbmigration.migratev1tov2(sessions)
return sessions
else:
query = Session.all()
query.filter("wave_id =", wave_id)
query.filter("wavelet_id =", wavelet_id)
sessions = query.fetch(100)
dbmigration.migratev1tov2(sessions)
memcache.add(key, sessions, time=memcacheConfig.DEFAULT_EXPIRE_SECS)
return sessions