本文整理汇总了Python中models.Player.get_or_insert方法的典型用法代码示例。如果您正苦于以下问题:Python Player.get_or_insert方法的具体用法?Python Player.get_or_insert怎么用?Python Player.get_or_insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.get_or_insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import get_or_insert [as 别名]
def __init__(self):
self.user = users.get_current_user()
# Creates a player if one does not already exist. No signup required!
self.player = Player.get_or_insert(self.user.user_id(), user = self.user, pseudonym = self.user.nickname())
self.template_values = {
'user' : self.user,
'player' : self.player,
'logout_url' : create_logout_url('/'),
'locations' : LOCATIONS,
}
logging.debug("Setting up template values %s" % (self.template_values))
示例2: DoGet
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import get_or_insert [as 别名]
def DoGet(self, league_key_name):
league_to_show = League.get_by_id(long(league_key_name))
league_name = league_to_show.name
logging.debug('Getting league %s' % league_to_show)
self.user = users.get_current_user()
# Creates a player if one does not already exist. No signup required!
self.player = Player.get_or_insert(self.user.user_id(), user = self.user, pseudonym = self.user.nickname(), league = league_to_show)
logging.info('creating player for user %s in league %s' % (self.player.pseudonym, league_name))
if not league_to_show:
self.error(404)
self.response.out.write("""<strong>No League with key %s.
Try looking through the <a href="/">list of leagues</a>.</strong>""" % league_name)
additional_values = {
'league_to_show' : league_to_show,
'players' : league_to_show.players(),
}
self.template_values.update(additional_values)
self.render_to_response("league.html")