Jump to: navigation, search

Report-writing tutorial

153 bytes added, 15:46, 30 October 2011
Update links
;Report class : This is the code that takes data from the GRAMPS database and organizes it into the document structure. This structure can later be printed, viewed, or written into a file in a variety of formats. This class uses the [ gen/gen_plug.html#module-gen.plug._docgenplugin docgen] interface to abstract away the output format details.
;Options class : This is the code that provides means to obtain options necessary for the report using a variety of available mechanisms.
==Document interface==
GRAMPS attempts to abstract the output document format away from the report. By coding to the [ Gramps/gen/gen_plug.html#module-gen.plug._docgenplugin docgen] class, the report can generate its output in the format desired by the end user. The document passed to the report (<tt>self.doc</tt>) could represent an HTML, OpenDocument, PDF or any of the other formats supported by the user. The report does not have to concern itself with the output format details, since all details are handled by the document object.
A document is composed of paragraphs, tables, and graphics objects. Tables and graphics objects will not be covered in this tutorial.
The Report class's constructor will initialize several variables for the user based off the passed values. They are:
;self.doc : The opened document instance ready for output. This is of the type [ gen/gen_plug.html#module-gen.plug._docgenplugin docgen], and is '''not''' a normal file object.
;self.database : The [ GrampsDbBase] database object.
;self.options_class : The [ _options ReportOptions] class passed to the report.
You'll probably need a start-person for which to write the report. This person should be obtained from the <tt>options_class</tt> object through the PersonOption class which will default to the active person in the database. Anything else the report class needs in order to produce the report should be obtained from the <tt>options_class</tt> object. For example, you may need to include the additional code in the report class constructor to obtain any options you defined for the report.
===Options class===
* Options class should derive from [ gen/gen_plug.html#module-gen.plug._options ReportOptions] class. Usually for a common report the <tt>MenuReportOptions</tt> class should be derived from. <tt>MenuReportOptions</tt> will abstract most of the lower-level widget handling below.
====Using ReportOptions====

Navigation menu