Commit 82291860 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_hal_json_style: fix severe performance issue with delete action

parent b947f4f3
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>python: (portal.portal_workflow.isTransitionPossible(object, \'delete\') or ((getattr(object, \'getParentValue\', None) is not None) and (portal.Base_checkPermission(object.getParentValue().getRelativeUrl(), \'Delete objects\')) and len([workflow for workflow in object.Base_getWorkflowHistory().keys() if workflow != \'edit_workflow\']) == 0)) and (object.getRelationCountForDeletion() == 0)</string> </value> <value> <string>python: object.isDeletable(check_relation=False)</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -6,23 +6,30 @@ intended to make code easy understanding ...@@ -6,23 +6,30 @@ intended to make code easy understanding
""" """
portal = context.getPortalObject() portal = context.getPortalObject()
request=container.REQUEST
history_dict = context.Base_getWorkflowHistory() def errorHandler():
history_dict.pop('edit_workflow', None) request.RESPONSE.setStatus(400)
form = getattr(context,form_id)
return context.ERP5Document_getHateoas(form=form, REQUEST=request, mode='form')
if history_dict == {} or context.getParentValue().portal_type == 'Preference': if context.isDeletable(check_relation=True):
try: if portal.portal_workflow.isTransitionPossible(context, 'delete'):
context.getParentValue().manage_delObjects( try:
ids= [context.getId()]) portal.portal_workflow.doActionFor(context, 'delete_action')
except ConflictError: except ConflictError:
raise return errorHandler()
except Exception: except Exception:
pass pass
else:
try:
context.getParentValue().manage_delObjects(
ids= [context.getId()])
except ConflictError:
return errorHandler()
except Exception:
pass
else: else:
try: return errorHandler()
portal.portal_workflow.doActionFor(context, 'delete_action')
except ConflictError:
raise
except:
pass
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