Commit 97c40dcb authored by Jérome Perrin's avatar Jérome Perrin

hal_json_style: after save, render next form later

We want to render the next page after interaction workflows are
executed.
parent fcde3e85
......@@ -2,7 +2,7 @@ from Acquisition import aq_self, aq_base, aq_inner
from Products.ERP5Type.Utils import UpperCase
from ZODB.POSException import ConflictError
from AccessControl import Unauthorized
import transaction
def Base_aqSelf(self):
return aq_self(self)
......@@ -103,3 +103,16 @@ def WorkflowTool_listActionParameterList(self):
return result_list
def Base_renderFormAtEndOfTransaction(self, request, response, form_id, **kw):
def renderFormAndSetResponseBody(context, request, response, form_id, **kw):
kw['message'] = request.get('portal_status_message') or kw['message']
response.setBody(context.Base_renderForm(form_id, **kw))
transaction.get().addBeforeCommitHook(
renderFormAndSetResponseBody, (
self,
request,
response,
form_id,), kw)
\ No newline at end of file
......@@ -254,9 +254,11 @@ if context.REQUEST.get('is_web_mode', False) and \
not editable_mode:
form_id = 'view'
# Directly render the form after a successful edit
# Directly render the form after a successful edit, but in a before commit
# hook, so that if interactions modify the state we render the new state.
# Cleanup formulator's special key in request to ensure field are only calculated from context and not the request anymore
for key in list(context.REQUEST.keys()):
if str(key).startswith('field') or str(key).startswith('subfield'):
context.REQUEST.form.pop(key, None)
return context.Base_renderForm(form_id, message=message)
return context.Base_renderFormAtEndOfTransaction(request, request.response, form_id, message=message)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>Base_renderFormAtEndOfTransaction</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>HalStyle</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_renderFormAtEndOfTransaction</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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