本文整理汇总了Python中springgrid.lib.base.Session.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Session.commit方法的具体用法?Python Session.commit怎么用?Python Session.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类springgrid.lib.base.Session
的用法示例。
在下文中一共展示了Session.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addmapifdoesntexist
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def addmapifdoesntexist(mapname, maparchivechecksum):
map = Session.query(Map).filter(Map.map_name == mapname).first()
if map == None:
try:
map = Map(mapname)
map.map_archivechecksum = maparchivechecksum
Session.add(map)
Session.commit()
except:
return (False, "error adding to db: " + str(sys.exc_value))
return (True, "")
if map.map_archivechecksum == None:
map.map_archivechecksum = maparchivechecksum
try:
Session.commit()
return (True, "")
except:
return (False, "error updating db: " + str(sys.exc_value))
if map.map_archivechecksum != maparchivechecksum:
return (False, "map archive checksum doesn't match the one already on the website.")
return (True, "")
示例2: setbotrunnernotsupportsthisai
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def setbotrunnernotsupportsthisai(botrunnername, ainame, aiversion):
botrunner = botrunnerhelper.getBotRunner( botrunnername )
for ai in botrunner.supportedais:
if ai.ai_base.ai_base_name == ainame and ai.ai_version == aiversion:
botrunner.supportedais.remove( ai )
Session.commit()
return (True,'')
示例3: addLeagueMatches
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def addLeagueMatches(league, matchRequestQueue, matchResults):
ais = Session.query(AI).join(LeagueAI).filter(LeagueAI.league_id ==\
league.league_id).all()
map = Session.query(Map).filter(Map.map_id == league.map_id).first()
mod = Session.query(Mod).filter(Mod.mod_id == league.mod_id).first()
playAgainstSelf = league.play_against_self
if league.side_modes == "xvsy":
sides = [int(i) for i in league.sides.split("vs")]
else:
sides = [int(league.sides)]
matchRequests = []
for i, ai0 in enumerate(ais[:-1]):
for j, ai1 in enumerate(ais[i:]):
if not playAgainstSelf and ai0.ai_id == ai1.ai_id:
continue
first = Session.query(ModSide).filter(ModSide.mod_side_id == sides[0]).first()
if len(sides) == 2:
second = Session.query(ModSide).filter(ModSide.mod_side_id == sides[1]).first()
allSides = [(first, second), (second, first)]
else:
allSides = [(first, first)]
for firstSide, secondSide in allSides:
for k in xrange(league.matches_per_ai_pair):
matchRequest = MatchRequest(ai0, ai1, map, mod,\
league.speed, league.soft_timeout, league.hard_timeout,\
firstSide, secondSide, league.league_id)
matchRequests.append(matchRequest)
#save all matches to the database
Session.add_all(matchRequests)
Session.commit()
示例4: storeresult
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def storeresult( botrunnername, matchrequest_id, result ):
# delete any existing result, saves doing check first...
matchrequest = getmatchrequest( matchrequest_id )
if matchrequest == None:
return
matchrequest.matchresult = MatchResult( result )
Session.commit()
示例5: setbotrunnersupportsthismap
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def setbotrunnersupportsthismap(botrunnername, mapname):
# Now, register the map as supported map
botrunner = botrunnerhelper.getBotRunner(botrunnername)
for map in botrunner.supportedmaps:
if map.map_name == mapname:
return (True, "")
map = getMap(mapname)
botrunner.supportedmaps.append(map)
Session.commit()
return (True, "")
示例6: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def add(self):
botrunnerName = self.form_result["botrunnerName"]
sharedSecret = self.form_result["sharedSecret"]
botrunner = BotRunner(botrunnerName, sharedSecret)
Session.add(botrunner)
Session.commit()
c.message = "Added ok"
return render('genericmessage.html')
示例7: remove
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def remove(self, id):
if not roles.isInRole(roles.modadmin):
c.message = "You must be logged in as a modadmin, temporary!"
return render('genericmessage.html')
engine = Session.query(Engine).filter(Engine.engine_id == id).first()
if engine == None:
c.message = "No such engine"
return render('genericmessage.html')
Session.delete(engine)
Session.commit()
c.message = "Deleted ok"
return render('genericmessage.html')
示例8: remove
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def remove(self, id):
if not roles.isInRole(roles.modadmin):
c.message = "You must be logged in as a modadmin"
return render("genericmessage.html")
mod = Session.query(Mod).filter(Mod.mod_id == id).first()
if mod == None:
c.message = "No such mod"
return render("genericmessage.html")
Session.delete(mod)
Session.commit()
c.message = "Deleted ok"
return render("genericmessage.html")
示例9: remove
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def remove(self, id):
if not roles.isInRole(roles.mapadmin):
c.message = "You must be logged in as a mapadmin"
return render('genericmessage.html')
map = Session.query(Map).filter(Map.map_id == id).first()
if map == None:
c.message = "No such map"
return render('genericmessage.html')
Session.delete(map)
Session.commit()
c.message = "Deleted ok"
return render('genericmessage.html')
示例10: remove
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def remove(self, id):
if not roles.isInRole(roles.aiadmin):
c.message = "You must be logged in as a aiadmin"
return render("genericmessage.html")
ai = Session.query(AI).filter(AI.ai_id == id).first()
if ai == None:
c.message = "No such ai"
return render("genericmessage.html")
Session.delete(ai)
Session.commit()
c.message = "Deleted ok"
return render("genericmessage.html")
示例11: remove
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def remove(self, id):
if not roles.isInRole(roles.leagueadmin):
c.message = "You must be logged in as a leagueadmin"
return render('genericmessage.html')
league = Session.query(League).filter(League.league_id == id).first()
if league == None:
c.message = "No such league"
return render('genericmessage.html')
Session.query(LeagueAI).filter(LeagueAI.league_id == id).delete()
Session.delete(league)
Session.commit()
c.message = "Deleted ok"
return render('genericmessage.html')
示例12: remove
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def remove(self, id):
if not roles.isInRole(roles.leagueadmin):
c.message = "You must be logged in as a leagueadmin"
return render('genericmessage.html')
request = Session.query(MatchRequest).filter(MatchRequest.matchrequest_id == id).first()
if request == None:
c.message = "No such request"
return render('genericmessage.html')
Session.delete(request)
Session.commit()
c.message = "Deleted ok"
return render('genericmessage.html')
示例13: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def add(self):
if not roles.isInRole(roles.modadmin):
c.message = "You must be logged in as a modadmin. Sorry, temporary"
return render('genericmessage.html')
enginename = self.form_result["engineName"]
enginearchivechecksum = self.form_result["engineArchiveChecksum"]
engineurl = self.form_result["engineUrl"]
engine = Engine(enginename)
engine.engine_url = engineurl
engine.engine_archivechecksum = enginearchivechecksum
Session.add(engine)
Session.commit()
c.message = "Added ok"
return render('genericmessage.html')
示例14: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def add(self):
if not roles.isInRole(roles.mapadmin):
c.message = "You must be logged in as a mapadmin"
return render('genericmessage.html')
mapname = self.form_result["mapName"]
maparchivechecksum = self.form_result["mapArchiveChecksum"]
mapurl = self.form_result["mapUrl"]
map = Map(mapname)
map.map_url = mapurl
map.map_archivechecksum = maparchivechecksum
Session.add(map)
Session.commit()
c.message = "Added ok"
return render('genericmessage.html')
示例15: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import commit [as 别名]
def add(self):
if not roles.isInRole(roles.modadmin):
c.message = "You must be logged in as a modadmin"
return render("genericmessage.html")
modname = self.form_result["modName"]
modarchivechecksum = self.form_result["modArchiveChecksum"]
modurl = self.form_result["modUrl"]
mod = Mod(modname)
mod.mod_url = modurl
mod.mod_archivechecksum = modarchivechecksum
Session.add(mod)
Session.commit()
c.message = "Added ok"
return render("genericmessage.html")