Yes. This is happening because there is a bug in Ignition with Gateway scripts. Gateways scripts still have the old legacy scoping enabled by default.
The bug is this: variables defined in the outermost scope can not be see by functions. In this case you have the generateReportPart variable that holds a function and you try to execute it in the generateReport function. This is perfect legal Python – but as I said the error occurs because of the scoping bug in Gateway scripts.
I wrote about the scope change in Ignition here: http://www.perfectabstractions.com/blog/new-scripting-features-in-ignition-77-part-1#standard-scoping
The best thing to do is write all your code in a project library function and then simply execute that function in your Gateway script.