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


Python Player.get_or_insert方法代码示例

本文整理汇总了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))
开发者ID:oby1,项目名称:oponger,代码行数:13,代码来源:base_handler.py

示例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")
开发者ID:jarajapu,项目名称:oponger,代码行数:24,代码来源:page_handlers.py


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