Commit 1a7b5349 authored by Jérome Perrin's avatar Jérome Perrin

deferred_style: factorize request argument filtering

This code was slightly different in three places:
 * Base_activateSimpleView: only use request.form.items()
 * Base_activateReport: use request.items()
 * Base_computeReportSection: use request.items()

request.items returns all items from request.other, request.form and
request.cookies.
In all cases, we are interested in request.form, so that report runs
with the same user input in request. We want to restore restore
request.other for Base_computeReportSection , but it does not harm in
other cases.
We always drop cookies to fix  #20180220-1DBF516 (as a consequence the
request will not strictly be identical, but rendering reports should not
depend on cookies)
parent fd398269
...@@ -22,20 +22,7 @@ if person_value.getDefaultEmailText('') in ('', None): ...@@ -22,20 +22,7 @@ if person_value.getDefaultEmailText('') in ('', None):
"You haven't defined your email address"))) "You haven't defined your email address")))
# save request parameters # save request parameters
# XXX we exclude some reserved names in a very ad hoc way request_form = portal.ERP5Site_filterRequestForDeferredStyle(request)
request_form = {}
for k, v in request.form.items():
if k not in ('TraversalRequestNameStack', 'AUTHENTICATED_USER', 'URL',
'SERVER_URL', 'AUTHENTICATION_PATH', 'USER_PREF_LANGUAGES', 'PARENTS',
'PUBLISHED', 'AcceptLanguage', 'AcceptCharset', 'RESPONSE',
'ACTUAL_URL'):
# XXX proxy fields stores a cache in request.other that cannot be pickled
if str(k).startswith('field__proxyfield'):
continue
# Remove FileUpload parameters
elif getattr(v, 'headers', ''):
continue
request_form[k] = v
localizer_language = portal.Localizer.get_selected_language() localizer_language = portal.Localizer.get_selected_language()
......
...@@ -22,21 +22,8 @@ format = request.get('format', '') ...@@ -22,21 +22,8 @@ format = request.get('format', '')
skin_name = request['deferred_portal_skin'] skin_name = request['deferred_portal_skin']
# save request parameters (after calling the report_method which may tweak the # save request parameters (after calling the report_method which may tweak the
# request). XXX we exclude some reserved names in a very ad hoc way # request).
request_other = {} request_other = portal.ERP5Site_filterRequestForDeferredStyle(request)
for k, v in request.items():
if k not in ('TraversalRequestNameStack', 'AUTHENTICATED_USER', 'URL',
'SERVER_URL', 'AUTHENTICATION_PATH', 'USER_PREF_LANGUAGES', 'PARENTS',
'PUBLISHED', 'AcceptLanguage', 'AcceptCharset', 'RESPONSE', 'SESSION',
'ACTUAL_URL'):
# XXX proxy fields stores a cache in request.other that cannot be pickled
if same_type(k, '') and k.startswith('field__proxyfield'):
continue
# Remove FileUpload parameters
elif getattr(v, 'headers', ''):
continue
request_other[k] = v
context.activate(activity="SQLQueue", tag=tag, after_tag=after_tag, context.activate(activity="SQLQueue", tag=tag, after_tag=after_tag,
......
...@@ -16,19 +16,7 @@ else: ...@@ -16,19 +16,7 @@ else:
raise ValueError, 'form meta_type (%r) unknown' %(form.meta_type,) raise ValueError, 'form meta_type (%r) unknown' %(form.meta_type,)
# Rebuild request_other as report section can have modify request content # Rebuild request_other as report section can have modify request content
request_other = {} request_other = portal.ERP5Site_filterRequestForDeferredStyle(request)
for k, v in request.items():
if k not in ('TraversalRequestNameStack', 'AUTHENTICATED_USER', 'URL',
'SERVER_URL', 'AUTHENTICATION_PATH', 'USER_PREF_LANGUAGES', 'PARENTS',
'PUBLISHED', 'AcceptLanguage', 'AcceptCharset', 'RESPONSE', 'SESSION',
'ACTUAL_URL'):
# XXX proxy fields stores a cache in request.other that cannot be pickled
if same_type(k, '') and str(k).startswith('field__proxyfield'):
continue
# Remove FileUpload parameters
elif getattr(v, 'headers', ''):
continue
request_other[k] = v
localizer_language = portal.Localizer.get_selected_language() localizer_language = portal.Localizer.get_selected_language()
active_process = portal.portal_activities.newActiveProcess() active_process = portal.portal_activities.newActiveProcess()
......
request_other = {}
for k, v in request.other.items() + request.form.items():
if k not in ('TraversalRequestNameStack', 'AUTHENTICATED_USER', 'URL',
'SERVER_URL', 'AUTHENTICATION_PATH', 'USER_PREF_LANGUAGES', 'PARENTS',
'PUBLISHED', 'AcceptLanguage', 'AcceptCharset', 'RESPONSE', 'SESSION',
'ACTUAL_URL', 'HTTP_COOKIE'):
# XXX proxy fields stores a cache in request.other that cannot be pickled
if same_type(k, '') and k.startswith('field__proxyfield'):
continue
# Remove FileUpload parameters
elif getattr(v, 'headers', ''):
continue
request_other[k] = v
return request_other
<?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>_params</string> </key>
<value> <string>request</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_filterRequestForDeferredStyle</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