本文整理汇总了Python中pynformatics.models.DBSession.merge方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.merge方法的具体用法?Python DBSession.merge怎么用?Python DBSession.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynformatics.models.DBSession
的用法示例。
在下文中一共展示了DBSession.merge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: problem_generate_samples
# 需要导入模块: from pynformatics.models import DBSession [as 别名]
# 或者: from pynformatics.models.DBSession import merge [as 别名]
def problem_generate_samples(request):
try:
checkCapability(request)
problem = DBSession.query(EjudgeProblem).filter(EjudgeProblem.id == request.matchdict['problem_id']).first()
problem.generateSamples()
# res = ""
# if problem.sample_tests != '':
# res = "<div class='problem-statement'><div class='sample-tests'><div class='section-title'>Примеры</div>"
#
# for i in problem.sample_tests.split(","):
# res += "<div class='sample-test'>"
# res += "<div class='input'><div class='title'>Входные данные</div><pre class='content'>"
# res += get_test(problem, i)
# res += "</pre></div><div class='output'><div class='title'>Выходные данные</div><pre class='content'>"
# res += get_corr(problem, i)
# res += "</pre></div></div>"
#
# res += "</div></div>"
#
# problem.sample_tests_html = res
with transaction.manager:
DBSession.merge(problem)
return {"result" : "ok", "content" : problem.sample_tests}
except Exception as e:
return {"result" : "error", "content" : e.__str__(), "stack" : traceback.format_exc()}
示例2: setShowLimits
# 需要导入模块: from pynformatics.models import DBSession [as 别名]
# 或者: from pynformatics.models.DBSession import merge [as 别名]
def setShowLimits(problem_id, show_limits):
problem = DBSession.query(Problem).filter(Problem.id == problem_id).first()
problem.show_limits = show_limits
with transaction.manager:
DBSession.merge(problem)
return "Ok"
示例3: approve
# 需要导入模块: from pynformatics.models import DBSession [as 别名]
# 或者: from pynformatics.models.DBSession import merge [as 别名]
def approve(request):
try:
id = int(html.escape(request.params['id']))
ideal = DBSession.query(Ideal).filter_by(id=id).first()
ideal.status = html.escape(request.params['status'])
with transaction.manager:
DBSession.merge(ideal)
return HTTPFound(location="/mod/statements/view3.php?chapterid=" + str(ideal.problem_id))
except Exception as e:
return {"result" : "error", "message" : e.__str__(), "stack" : traceback.format_exc()}
示例4: problem_set_preliminary
# 需要导入模块: from pynformatics.models import DBSession [as 别名]
# 或者: from pynformatics.models.DBSession import merge [as 别名]
def problem_set_preliminary(request):
try:
checkCapability(request)
problem = DBSession.query(Problem).filter(Problem.id == request.matchdict['problem_id']).first()
problem.sample_tests = request.params['sample_tests']
with transaction.manager:
DBSession.merge(problem)
return {"result" : "ok", "content" : problem.sample_tests}
except Exception as e:
return {"result" : "error", "content" : e.__str__(), "stack" : traceback.format_exc()}