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


Python Session.flush方法代码示例

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


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

示例1: addstaticdata

# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import flush [as 别名]
def addstaticdata():
    rolerows = Session.query(Role).all()
    for rolename in [ 'accountadmin', 'aiadmin', 'mapadmin', 'modadmin', 'leagueadmin', 'botrunneradmin', 'requestadmin', 'apiclient' ]:
        rolefound = False
        for rolerow in rolerows:
            if rolerow.role_name == rolename:
                rolefound = True
        if not rolefound:
            role = Role(rolename)
            Session.add(role)
            Session.flush()
开发者ID:gajop,项目名称:springgrid,代码行数:13,代码来源:roles.py

示例2: applydefaults

# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import flush [as 别名]
def applydefaults():
    global defaults
    for key_name in defaults.keys():
        configrow = Session.query(Config).filter(Config.config_key == key_name).first()
        if configrow == None:
            setValue(key_name, defaults[key_name])
    # purge extraneous values
    for configrow in Session.query(Config):
        if not defaults.has_key(configrow.config_key):
            Session.delete(configrow)
    Session.flush()
开发者ID:gajop,项目名称:springgrid,代码行数:13,代码来源:confighelper.py

示例3: addaiifdoesntexist

# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import flush [as 别名]
def addaiifdoesntexist(ainame, aiversion):
    ai = getAI(ainame, aiversion)
    if ai == None:
        ai_base = Session.query(AIBase).filter(AIBase.ai_base_name == 
                                ainame).first()
        if ai_base == None:
            ai_base = AIBase(ainame)
            Session.add(ai_base)
            Session.flush()
        ai_base_id = ai_base.ai_base_id
        try:
            ai = AI(ai_base_id, aiversion)
            Session.add(ai)
            Session.commit()
        except:
            print sys.exc_value
            return(False, "error adding to db: " + str(sys.exc_value))

    return (True,'')
开发者ID:gajop,项目名称:springgrid,代码行数:21,代码来源:aihelper.py

示例4: add

# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import flush [as 别名]
    def add(self):
        if not roles.isInRole(roles.leagueadmin):
            c.message = "You must be logged in as a leagueadmin"
            return render('genericmessage.html')

        leagueName = self.form_result["leagueName"]
        modId = self.form_result["modId"]
        mapId = self.form_result["mapId"]
        speed = self.form_result["speed"]
        softtimeout = self.form_result["softtimeout"]
        hardtimeout = self.form_result["hardtimeout"]
        nummatchesperaipair = self.form_result["nummatchesperaipair"]
        sides = self.form_result["sides"]
        sidemodes = self.form_result["sidemodes"]
        playagainstself = self.form_result["playagainstself"]
        account = Session.query(Account).filter(Account.username == session['user']).first()
        ais = []
        for i in range(Session.query(AI).count()):
            ai_i = 'ai_checkbox_' + str(i)
            if (self.form_result.has_key(ai_i)):
                ais.append(i)

        league = League(leagueName, account, modId, mapId,
                nummatchesperaipair, speed, softtimeout, hardtimeout,
                sides, sidemodes, playagainstself)
        leagueais = [LeagueAI(ai, league) for ai in ais]
        Session.add(league)
        Session.add_all(leagueais)        
        
        matchrequests = Session.query(MatchRequest).filter(MatchRequest.league_id ==\
                league.league_id)         
        matchresults = [req for req in matchrequests if req.matchresult != None] 
        
        matchscheduler.addLeagueMatches(league, matchrequests, matchresults)
        Session.flush()
        Session.commit()
        
        redirect(url(controller='league', action='view', id=league.league_id))
开发者ID:gajop,项目名称:springgrid,代码行数:40,代码来源:league.py


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