本文整理匯總了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()}