Commit 63709fd4 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

...

This is a follow up commit to cd18daf4,
to fix the behavior in WSGI.

Zope WSGI no longer works like Medusa in the case of "response.write".
Before this change, the response contained the contents of
"response.stdout" (which we want), plus the contents of the body (the
traceback created by the raised Exception, which we do not want). Note
that the "content-length" header was not correctly set either, and parts
of the response were cut off.

Reminder: raising an exception is done in order to doom the transaction.

We are working on reimplementing WSGI/Medusa compatible streaming in a
better way in the near future; this commit is a temporary fix.
parent cd18daf4
......@@ -2,7 +2,7 @@ def respond(v):
if REQUEST is None:
return v
REQUEST.RESPONSE.setHeader("Content-Type", "text/html")
REQUEST.RESPONSE.write(v)
raise ValueError("Abort Transaction")
REQUEST.RESPONSE.setBody(v, lock=True)
raise Exception
return respond(context.Base_formatDiffObjectListToHTML(context.BusinessTemplate_getDiffObjectListFromZODB(detailed=detailed)))
def respond(v):
if REQUEST is None:
return v
REQUEST.RESPONSE.write(v)
raise ValueError("Abort Transaction")
REQUEST.RESPONSE.setBody(v, lock=True)
raise Exception
return respond(context.Base_formatDiffObjectListToText(context.BusinessTemplate_getDiffObjectListFromZODB(detailed=detailed)))
......@@ -57,8 +57,9 @@ category_list_spreadsheet_dict = context.Base_getCategoriesSpreadSheetMapping(
if detailed_report_result:
REQUEST.other['portal_status_message'] = translateString('Spreasheet contains errors')
REQUEST.other['category_import_report'] = detailed_report_result
REQUEST.RESPONSE.write(portal_categories.CategoryTool_viewImportReport().encode('utf-8'))
raise Exception('Spreadsheet contains errors')
REQUEST.RESPONSE.setBody(portal_categories.CategoryTool_viewImportReport().encode('utf-8'), lock=True)
# Spreadsheet contains errors
raise Exception
for base_category, category_list in category_list_spreadsheet_dict.iteritems():
total_category_counter += len(category_list)
......@@ -211,8 +212,9 @@ if detailed_report:
REQUEST.other['category_import_report'] = detailed_report_result
result = portal_categories.CategoryTool_viewImportReport().encode('utf-8')
if simulation_mode:
REQUEST.RESPONSE.write(result)
raise Exception('Dry run')
REQUEST.RESPONSE.setBody(result, lock=True)
# Dry run
raise Exception
return result
portal_categories.Base_redirect(
keep_items={
......
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