Commit 899234ad authored by Vincent Pelletier's avatar Vincent Pelletier

Alarm_acceptSubmittedCredentialList: Activate "accept" transition.

This removes the need for limitting the number of documents to
process in a single transaction, thanks to searchAndActivate.
Also, handle catalog desynchronisation gracefuly in the event
of accept/accept race condition.
parent 0c5ca725
......@@ -50,57 +50,34 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>limit = context.getProperty(\'limit\', 100)\n
<value> <string>portal = context.getPortalObject()\n
portal_preferences = portal.portal_preferences\n
searchAndActivate_ = portal.portal_catalog.searchAndActivate\n
def searchAndActivate(**kw):\n
searchAndActivate_(\'Credential_accept\', **kw)\n
\n
portal = context.getPortalObject()\n
portal_type_list = []\n
if portal_preferences.getPreferredCredentialRequestAutomaticApproval():\n
portal_type_list.append(\'Credential Request\')\n
if portal_preferences.getPreferredCredentialRecoveryAutomaticApproval():\n
portal_type_list.append(\'Credential Recovery\')\n
if portal_type_list:\n
searchAndActivate(\n
portal_type=portal_type_list,\n
validation_state=\'submitted\',\n
)\n
\n
if portal.portal_preferences.getPreferredCredentialRequestAutomaticApproval():\n
module = context.getDefaultModule(\'Credential Request\')\n
result = module.searchFolder(portal_type=\'Credential Request\',\n
validation_state=\'submitted\',\n
limit=limit)\n
for document in result:\n
if document.getValidationState() == \'submitted\':\n
document.accept()\n
\n
if portal.portal_preferences.getPreferredPersonCredentialUpdateAutomaticApproval() and \\\n
portal.portal_preferences.getPreferredOrganisationCredentialUpdateAutomaticApproval():\n
module = context.getDefaultModule(\'Credential Update\')\n
result = module.searchFolder(portal_type=\'Credential Update\',\n
validation_state=\'submitted\',\n
limit=limit)\n
for document in result:\n
if document.getValidationState() == \'submitted\':\n
document.accept()\n
elif portal.portal_preferences.getPreferredPersonCredentialUpdateAutomaticApproval() and \\\n
not portal.portal_preferences.getPreferredOrganisationCredentialUpdateAutomaticApproval():\n
module = context.getDefaultModule(\'Credential Update\')\n
result = module.searchFolder(portal_type=\'Credential Update\',\n
validation_state=\'submitted\',\n
limit=limit)\n
for document in result:\n
if document.getDestinationDecisionValue().getPortalType() == \'Person\':\n
if document.getValidationState() == \'submitted\':\n
document.accept()\n
elif not portal.portal_preferences.getPreferredPersonCredentialUpdateAutomaticApproval() and \\\n
portal.portal_preferences.getPreferredOrganisationCredentialUpdateAutomaticApproval():\n
module = context.getDefaultModule(\'Credential Update\')\n
result = module.searchFolder(portal_type=\'Credential Update\',\n
validation_state=\'submitted\',\n
limit=limit)\n
for document in result:\n
if document.getDestinationDecisionValue().getPortalType() == \'Organisation\':\n
if document.getValidationState() == \'submitted\':\n
document.accept()\n
\n
if portal.portal_preferences.getPreferredCredentialRecoveryAutomaticApproval():\n
module = context.getDefaultModule(\'Credential Recovery\')\n
result = module.searchFolder(portal_type=\'Credential Recovery\',\n
validation_state=\'submitted\',\n
limit=limit)\n
for document in result:\n
if document.getValidationState() == \'submitted\':\n
document.accept()\n
credential_update_destination_decision_portal_type_list = []\n
if portal_preferences.getPreferredPersonCredentialUpdateAutomaticApproval():\n
credential_update_destination_decision_portal_type_list.append(\'Person\')\n
if portal_preferences.getPreferredOrganisationCredentialUpdateAutomaticApproval():\n
credential_update_destination_decision_portal_type_list.append(\'Organisation\')\n
if credential_update_destination_decision_portal_type_list:\n
searchAndActivate(\n
portal_type=\'Credential Update\',\n
destination_decision_portal_type=credential_update_destination_decision_portal_type_list,\n
validation_state=\'submitted\',\n
)\n
</string> </value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Intent is to ignore accept/accept race conditions but complain about\n
any other race condition (ex: accept/reject).\n
"""\n
if context.getValidationState() != \'accepted\':\n
context.accept()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Credential_accept</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
436
437
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment