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(
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'))
REQUEST.RESPONSE.setBody(portal_categories.CategoryTool_viewImportReport().encode('utf-8'), lock=True)
REQUEST.RESPONSE.setStatus(200, 'OK', lock=True)
raise Exception('Spreadsheet contains errors')
for base_category, category_list in category_list_spreadsheet_dict.iteritems():
......@@ -209,8 +210,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)
REQUEST.RESPONSE.setStatus(200, 'OK', lock=True)
raise Exception('Dry run')
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