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


Python Session.countspeakers方法代码示例

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


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

示例1: _cacheFeaturedSpeaker

# 需要导入模块: from models import Session [as 别名]
# 或者: from models.Session import countspeakers [as 别名]
 def _cacheFeaturedSpeaker(self):
     """
     Create memcache for a featured Speaker of a conference.
     """
     # Get the conference that the speaker is speaking
     # at from the websafeKey provided in the request
     conf_k = ndb.Key(urlsafe=self.request.get('key'))
     conf = conf_k.get()
     # The speaker that was just added
     addedSpeaker = self.request.get('speaker')
     # Find the speaker in the most sessions giving a Confenence
     # and return (name, sessionsCount)
     featuredSpeaker = Session.countspeakers(conf_k)
     speakerName = featuredSpeaker[0]
     sessionsSpeakersIn = featuredSpeaker[1]
     speakerMemKey = SPEAKER_ANNOUNCEMENTS_KEY + self.request.get('key')
     # Query that gets the name of the sessions the features speaker
     sessionsInfo = [session.name for session in \
         Session.query(ancestor=conf_k, projection=[Session.name]).\
         filter(Session.speaker == speakerName)]
     # Turn array into string then remove []
     if sessionsSpeakersIn > 1 and speakerName == addedSpeaker:
         speaker = {
             "name": speakerName.title(),
             "conf_name": conf.name.title(),
             "sessions": sessionsInfo
         }
         memcache.add(key=speakerMemKey, value=speaker, time=600)
     else:
         # If no feature speaker
         speaker = ""
         memcache.delete(speakerMemKey)
     return speaker
开发者ID:Sesshoumaru404,项目名称:Conference-Organization-App,代码行数:35,代码来源:conference.py


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