request not defined in export functions
By accident (not having defined XLSX_DATE in settings.py) during xml export I encountered a bug in the exception code, showing an error message that "request" was not defined:
except:
messages.error(request, "Unexpected error ....)
Possible solutions:
1) remove message.error() lines from the export functions
2) pass the complete request object as first parameter to the export functions in exportviews.py instead of request.GET
Personally I think option 2 is best; do you agree @edmcdonagh ?
Comments (8)
-
-
reporter you tell me.. I didn't write the code :-)
My best guess would be that messages.error() is responsible for showing the error message in the export-GUI. -
That's the thing. It won't! It may have be done with an earlier implementation, but now exports are asynchronous and nothing to do with the request once they have been started.
The message in the interface is controlled by the status element.
-
reporter In that case, I suggest replacing:
messages.error(request, "Unexpected error creating temporary file - please contact an administrator: {0}".format(sys.exc_info()[0]))
by:
tsk.progress = 'Unexpected error creating temporary file - please contact an administrator: {0}'.format(sys.exc_info()[0]) tsk.save()
Btw.. I also noticed that after pressing "Export to XLSX" the status field is not updated automatically; it requires a page refresh or manual click on the "exports" menu item. Does that happen at your end as well, or should I open a new issue for that?
-
Regarding the last point, the exports page checks for current jobs on page load, and if it finds one it sets a page reload time of 3s. What you are finding is that the page loads before the task starts, so the reload isn't set.
The proper solution is to replace that with an AJAX section so that it continuously checks and just reloads that section of the page, not the whole thing.
Another thing that's been on my to do list for years, never quite getting to the top as it kind of works as is!
-
- changed milestone to 0.8.0
- changed component to Export: All
-
assigned issue to
-
- changed status to resolved
This has been fixed along the way when restructuring the exports. Point about export page is covered in issue ref
#575 -
Added ref
#490to changes→ <<cset 6a7c73c45a3c>>
- Log in to comment
I'm not sure. I haven't looked at the code, and I don't think I'll get time to today.
Instinctively, I'm not sure how useful the request object is in the export error messages - what do we want to find out from it?