Changes

Jump to: navigation, search

Report-writing tutorial

117 bytes added, 12:50, 30 October 2011
Report class
==Defining the classes==
===Report class===
The user's report class should inherit from the Report class contained within the Report module. The constructor should take two three arguments (besides class instance itself, usually denoted by 'self' name):
* GRAMPS database instance
* options class instance
* user class instanceThe 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 import Report, ReportUtils, ReportOptions
class ReportClassName(Report):
def __init__(self, database, options_class, user): Report.__init__(self, database, options_class, user)
</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 the type [http://www.gramps-project.org/docs / docgen], and is '''not''' a normal file object.
;self.database : The [http://www.gramps-project.org/docs/gen/gen_lib.html#module-gen.lib GrampsDbBase] database object.
;self.options_class : The [http://www.gramps-project.org/devdoc/api/2.2/private/ReportBase._ReportOptions.ReportOptions-class.html ReportOptions] class passed to the report.

Navigation menu