本文整理汇总了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]