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