本文整理汇总了Python中springgrid.lib.base.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类springgrid.lib.base.Session
的用法示例。
在下文中一共展示了Session.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addmapifdoesntexist
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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')
示例3: addstaticdata
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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()
示例4: setValue
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [as 别名]
def setValue(key_name, key_value):
global defaults
if not defaults.has_key(key_name):
raise Exception("confighelper.setvalue, no such key_name: " + key_name)
configrow = Session.query(Config).filter(Config.config_key == key_name).first()
if configrow == None:
config = Config(key_name, key_value)
Session.add(config)
else:
configrow.setValue(key_value)
示例5: logonUserWithAuthenticatedOpenID
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [as 别名]
def logonUserWithAuthenticatedOpenID(openidurl):
account = None
# note: this could be optimized a little...
for thisaccount in Session.query(Account):
for openid in thisaccount.openids:
if openid.openid == openidurl:
account = thisaccount
if account == None:
# create new account
account = Account(openidurl, openidurl)
account.openids.append(OpenID(openidurl))
Session.add(account)
session['username'] = openidurl
示例6: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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")
示例7: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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')
示例8: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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')
示例9: validatesharedsecret
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [as 别名]
def validatesharedsecret(lbotrunnername, sharedsecret):
global botrunnername
botrunner = getBotRunner(lbotrunnername)
if botrunner == None:
# Never seen this botrunner before, just add it
botrunner = BotRunner(lbotrunnername, sharedsecret)
Session.add(botrunner)
Session.commit()
# if this fails, return true anyway
return True
else:
if botrunner.botrunner_sharedsecret == sharedsecret:
botrunnername = lbotrunnername
return True
return False
示例10: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [as 别名]
def add(self):
if not roles.isInRole(roles.accountadmin):
c.message = "You must be logged in as a accountadmin"
return render('genericmessage.html')
username = self.form_result['username']
userfullname = self.form_result['userfullname']
email = self.form_result['email']
password = self.form_result['password']
account = Account(username, userfullname)
account.passwordinfo = PasswordInfo(password)
account.email = email
Session.add(account)
Session.commit()
c.message = "Added ok"
return render('genericmessage.html')
示例11: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [as 别名]
def add(self):
if not roles.isInRole(roles.aiadmin):
c.message = "You must be logged in as aiadmin"
return render("genericmessage.html")
aiName = self.form_result["aiName"]
aiVersion = self.form_result["aiVersion"]
downloadUrl = self.form_result["downloadUrl"]
needsCompiling = self.form_result["needsCompiling"]
ai = AI(aiName, aiVersion)
ai.ai_downloadurl = downloadUrl
ai.ai_needscompiling = needsCompiling
ai.owneraccount = accounthelper.getAccount(session["user"])
Session.add(ai)
Session.commit()
c.message = "Added ok"
return render("genericmessage.html")
示例12: submit
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [as 别名]
def submit(self):
map = Session.query(Map).filter(Map.map_name == self.form_result['mapname']).first()
mod = Session.query(Mod).filter(Mod.mod_name == self.form_result['modname']).first()
ai0 = Session.query(AI).filter(AI.ai_id == self.form_result['ai0']).first()
ai1 = Session.query(AI).filter(AI.ai_id == self.form_result['ai1']).first()
ai0side = Session.query(ModSide).filter(ModSide.mod_side_id == self.form_result['ai0side']).first()
ai1side = Session.query(ModSide).filter(ModSide.mod_side_id == self.form_result['ai1side']).first()
matchrequest = MatchRequest(ai0 = ai0, ai1 = ai1, map = map, mod = mod,
speed = self.form_result['speed'],
softtimeout = self.form_result['softtimeout'],
hardtimeout = self.form_result['hardtimeout'],
ai0_side=ai0side, ai1_side=ai1side)
Session.add(matchrequest)
Session.commit()
return "Submitted ok."
示例13: addaiifdoesntexist
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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,'')
示例14: add
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [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))
示例15: addmatchrequest
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import add [as 别名]
def addmatchrequest(ai0, ai1, mod, map, speed, softtimeout, hardtimeout):
newmatchrequest = MatchRequest(ai0 = ai0, ai1 = ai1, mod = mod, map = map, speed = speed, softtimeout = softtimeout, hardtimeout = hardtimeout)
Session.add(newmatchrequest)