From d88e5bc0e6583785eb511f9af933a81acfd3b3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Wed, 20 Jul 2011 10:03:29 +0200 Subject: [PATCH] Protect against during indexation concurrency. As users can double click (or register in same time with same reference) during time of indexation, it is required to lock on activity system. Note that as reference is global in the system, same tag, as in Document.Person._setReference is used. --- .../CredentialRequest_checkLoginAvailability.xml | 7 +++++++ .../erp5_credential/ERP5Site_newCredentialRequest.xml | 3 +++ bt5/erp5_credential/bt/revision | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml index 4f0be4c72f..2739a71225 100644 --- a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml +++ b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.xml @@ -57,6 +57,13 @@ Parameters:\n value -- field value (string)\n REQUEST -- standard REQUEST variable"""\n \n +if value:\n + # Same tag is used as in Document.Person._setReference, in order to protect against\n + # concurrency between Credential Request and Person object too\n + tag = \'Person_setReference_%s\' % value.encode(\'hex\')\n + if context.getPortalObject().portal_activities.countMessageWithTag(tag):\n + return False\n +\n def getRealContext():\n if not REQUEST:\n return context\n diff --git a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_newCredentialRequest.xml b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_newCredentialRequest.xml index b1bca901b3..87e417a4d7 100644 --- a/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_newCredentialRequest.xml +++ b/bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_newCredentialRequest.xml @@ -90,6 +90,9 @@ credential_request = module.newContent(\n date_of_birth=date_of_birth)\n \n credential_request.setCategoryList(category_list)\n +# Same tag is used as in Document.Person._setReference, in order to protect against\n +# concurrency between Credential Request and Person object too\n +credential_request.reindexObject(activate_kw=dict(tag=\'Person_setReference_%s\' % reference.encode(\'hex\')))\n \n #We attach the current user to the credential request if not anonymous\n if not context.portal_membership.isAnonymousUser():\n diff --git a/bt5/erp5_credential/bt/revision b/bt5/erp5_credential/bt/revision index e8930b6df9..55f04f2ae2 100644 --- a/bt5/erp5_credential/bt/revision +++ b/bt5/erp5_credential/bt/revision @@ -1 +1 @@ -364 \ No newline at end of file +365 \ No newline at end of file -- 2.30.9