本文整理汇总了Python中models.TestResult.chooseExperiment方法的典型用法代码示例。如果您正苦于以下问题:Python TestResult.chooseExperiment方法的具体用法?Python TestResult.chooseExperiment怎么用?Python TestResult.chooseExperiment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.TestResult
的用法示例。
在下文中一共展示了TestResult.chooseExperiment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
# 需要导入模块: from models import TestResult [as 别名]
# 或者: from models.TestResult import chooseExperiment [as 别名]
def process_request(self, request):
#noinspection PyBroadException
if not AB_TEST_ACTIVE:
return None
try:
sessionTests = request.session.get(AB_TEST_SESSION_NAME, {})
if sessionTests is None: sessionTests = {}
newSessionTests = {}
requestTests = ABTestRequest()
for activeTest in Test.objects.filter(active=True):
if activeTest.pk in sessionTests and TestResult.objects.filter(pk=sessionTests[activeTest.pk]).exists():
activeTestResult = TestResult.objects.get(pk=sessionTests[activeTest.pk])
else:
activeTestResult = TestResult.chooseExperiment(request, activeTest)
newSessionTests[activeTest.pk] = activeTestResult.pk
requestTests[activeTest] = activeTestResult
request.session[AB_TEST_SESSION_NAME] = newSessionTests
setattr(request, AB_TEST_REQUEST_NAME, requestTests)
except Exception as ex:
getLogger(AB_TEST_LOGGER_MIDDLEWARE).error("error processing request: %s", ex)
if not AB_TEST_FAIL_SILENT_MIDDLEWARE:
raise
return None