本文整理匯總了Python中pynformatics.models.DBSession.flush方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.flush方法的具體用法?Python DBSession.flush怎麽用?Python DBSession.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pynformatics.models.DBSession
的用法示例。
在下文中一共展示了DBSession.flush方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: updateOrAddProblem
# 需要導入模塊: from pynformatics.models import DBSession [as 別名]
# 或者: from pynformatics.models.DBSession import flush [as 別名]
def updateOrAddProblem(problem_id, contest, ejudgeCfg, update_statement = False):
problem = DBSession.query(EjudgeProblem).filter(EjudgeProblem.contest_id == contest.id).filter(EjudgeProblem.problem_id == problem_id).first()
problemCfg = ejudgeCfg.getProblem(problem_id)
if problem == None:
ejudge_problem = EjudgeProblemDummy(problemCfg.long_name, contest.id, problem_id, problemCfg.short_name, contest.ejudge_int_id)
with transaction.manager:
DBSession.add(ejudge_problem)
transaction.commit()
ejudge_problem = DBSession.query(EjudgeProblemDummy).filter(EjudgeProblemDummy.contest_id == contest.id).filter(EjudgeProblemDummy.problem_id == problem_id).first()
problem = Problem(problemCfg.long_name, problemCfg.time_limit, problemCfg.memory_limit, problemCfg.output_only, "<p>Условие пока не опубликовано...</p>", pr_id=ejudge_problem.ejudge_prid)
with transaction.manager:
DBSession.add(problem)
transaction.commit()
problem = DBSession.query(EjudgeProblem).filter(EjudgeProblem.contest_id == contest.id).filter(EjudgeProblem.problem_id == problem_id).first()
action = "add"
content = ""
else:
session = DBSession()
problem.ejudge_name = "" + problemCfg.long_name
problem.name = "" + problemCfg.long_name
if problem.name == "":
problem.name = " " #мы не хотим иметь пустые имена
problem.timelimit = problemCfg.time_limit
problem.memorylimit = problemCfg.memory_limit
problem.output_only = problemCfg.output_only
problem.short_id = problemCfg.short_name
if update_statement:
content = updateStatement(problem, problemCfg, contest, ejudgeCfg)
session.flush()
#session.commit()
transaction.commit()
# DBSession.commit()
action = "edit"
return [problem, problemCfg, action, content]