Jam.py documentation

generate

generate(self)

domain: client

language: python

class Report class

Description

The method is used internally to generate the content of the report.

When a server gets a request from a client to generate report, it first of all creates a copy of the report and then this copy calls the method.

This method triggers the on_before_generate event.

If the report template is defined, parses it and triggers on_parsed and on_generate events.

In the on_generate event handler developer should write a code that generates the content of the report and saves it in the ods file, by using the print_band method to print bands .

When the report is generated and the value of report extension attribute, set on the client, is not equal ods, the server tries to convert the ods file.

To convert the file, it first checks if the report group (owner of the report) has on_convert_report event handler. If this handler is defined it uses it to convert the report. Otherwise it uses for conversion the LibreOffice installed on the server in headless mode.

After that the application saves generated report to a file in a report folder of the static directory, set the value of the report_filename attribute to the name of the saved file, generates the value of the report_url attribute and triggers on_after_generate event.

Once the report is generated it is saved in a report folder of the static directory and the server sends the client the report file url.

If the report template attribute is not set, the server triggers the on_generate and after that on_after_generate events. In this case you should save the generated content to a file yourself and and set a value of the report_url attribute.