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 @@
<dictionary>
<item>
<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>
</dictionary>
</pickle>
......
......@@ -6,23 +6,30 @@ intended to make code easy understanding
"""
portal = context.getPortalObject()
request=container.REQUEST
history_dict = context.Base_getWorkflowHistory()
history_dict.pop('edit_workflow', None)
def errorHandler():
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):
if portal.portal_workflow.isTransitionPossible(context, 'delete'):
try:
portal.portal_workflow.doActionFor(context, 'delete_action')
except ConflictError:
return errorHandler()
except Exception:
pass
else:
try:
context.getParentValue().manage_delObjects(
ids= [context.getId()])
except ConflictError:
raise
return errorHandler()
except Exception:
pass
else:
try:
portal.portal_workflow.doActionFor(context, 'delete_action')
except ConflictError:
raise
except:
pass
return errorHandler()
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