Changes

From Gramps

Report-writing tutorial

32 bytes added, 09:46, 26 November 2025
m
Report class: Defined more precisely types of self.doc, self.database and Report
==Defining the classes==
===Report class===
The user's report class should inherit from the Report class contained within the Report <code>gramps.gen.plug.report</code> module. The constructor should take three arguments (besides class instance itself, usually denoted by 'self' name):
* Gramps database instance
* options class instance
The first is the database to work with. The second is the instance of the options class defined in the same report, see next section. The third is an instance of the User class, used for interaction with the user. Here's an example of a report class definition:
<pre>
from ReportBase gramps.gen.plug.report import Report, ReportUtils, ReportOptions
class ReportClassName(Report):
</pre>
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 one of the type [https://gramps-project.org/docs/gen/gen_plug.html#module-gramps.gen.plug._docgenplugin docgen.basedoc DocGen's Generator]types, and is '''not''' a normal file object.;self.database : The [https://www.gramps-project.org/docs/gen/gen_db.html#module-gramps.gen.db.base GrampsDbBase.DbReadBase DbReadBase] database object.
;self.options_class : The [https://www.gramps-project.org/docs/gen/gen_plug.html#gramps.gen.plug.report._options.ReportOptions ReportOptions] class passed to the report.
64
edits

Navigation menu