Commit 7cab5673 authored by Jérome Perrin's avatar Jérome Perrin

core: make category import compatible with WSGI

RESPONSE.write cannot be used with WSGI, so use another trick to return
a response without commiting the transaction.
parent 85417113
...@@ -57,7 +57,8 @@ category_list_spreadsheet_dict = context.Base_getCategoriesSpreadSheetMapping( ...@@ -57,7 +57,8 @@ category_list_spreadsheet_dict = context.Base_getCategoriesSpreadSheetMapping(
if detailed_report_result: if detailed_report_result:
REQUEST.other['portal_status_message'] = translateString('Spreasheet contains errors') REQUEST.other['portal_status_message'] = translateString('Spreasheet contains errors')
REQUEST.other['category_import_report'] = detailed_report_result REQUEST.other['category_import_report'] = detailed_report_result
REQUEST.RESPONSE.write(portal_categories.CategoryTool_viewImportReport().encode('utf-8')) REQUEST.RESPONSE.setBody(portal_categories.CategoryTool_viewImportReport().encode('utf-8'), lock=True)
REQUEST.RESPONSE.setStatus(200, 'OK', lock=True)
raise Exception('Spreadsheet contains errors') raise Exception('Spreadsheet contains errors')
for base_category, category_list in category_list_spreadsheet_dict.iteritems(): for base_category, category_list in category_list_spreadsheet_dict.iteritems():
...@@ -209,7 +210,8 @@ if detailed_report: ...@@ -209,7 +210,8 @@ if detailed_report:
REQUEST.other['category_import_report'] = detailed_report_result REQUEST.other['category_import_report'] = detailed_report_result
result = portal_categories.CategoryTool_viewImportReport().encode('utf-8') result = portal_categories.CategoryTool_viewImportReport().encode('utf-8')
if simulation_mode: if simulation_mode:
REQUEST.RESPONSE.write(result) REQUEST.RESPONSE.setBody(result, lock=True)
REQUEST.RESPONSE.setStatus(200, 'OK', lock=True)
raise Exception('Dry run') raise Exception('Dry run')
return result return result
portal_categories.Base_redirect( portal_categories.Base_redirect(
......
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