本文整理汇总了Python中models.Session.get_session_by_conferencekey方法的典型用法代码示例。如果您正苦于以下问题:Python Session.get_session_by_conferencekey方法的具体用法?Python Session.get_session_by_conferencekey怎么用?Python Session.get_session_by_conferencekey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Session
的用法示例。
在下文中一共展示了Session.get_session_by_conferencekey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getSessions
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import get_session_by_conferencekey [as 别名]
def _getSessions(self, webSafeKey):
"""Get all sessions from a conference."""
confkey = ndb.Key(urlsafe=webSafeKey)
# check if this key belongs to an actual conference
if not confkey:
raise endpoints.NotFoundException('No conference found with this key.')
# retrieve all sessions from ancestor conferences, using
# an ndb class method actual query is faster
return Session.get_session_by_conferencekey(confkey)
示例2: _setFeaturedSpeaker
# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import get_session_by_conferencekey [as 别名]
def _setFeaturedSpeaker(speaker, webSafeKey):
"""This will check if the speaker is featured in more
than one session then it will create an anouncement
assigning it to memcache.
"""
# get all existing sessions
confkey = ndb.Key(urlsafe=webSafeKey)
all_sessions = Session.get_session_by_conferencekey(confkey)
# check to see if speaker is present already in other sessions
speaker_sessions = all_sessions.filter(Session.speaker == speaker)
if speaker_sessions.count() > 1:
announcement = '%s %s %s %s' % (
'This speaker is very popular:',
speaker,
'. He is featured in these sessions:',
', '.join(sess.name for sess in speaker_sessions))
memcache.set(FEATURED_SPEAKER_SESSIONS_KEY, announcement)
else:
# delete the memcache announcements entry
announcement = ""
memcache.delete(FEATURED_SPEAKER_SESSIONS_KEY)
return announcement