From 77af7ed092645e26bb38ce12d9b2f179f8efd408 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Thu, 24 Jan 2008 12:50:33 +0000 Subject: [PATCH] Refactoring the report system: reports no longer require dbstate. svn: r9924 --- ChangeLog | 27 +++++++++++++++++++++++ src/PluginUtils/_GuiOptions.py | 6 +++--- src/ReportBase/_CommandLineReport.py | 3 ++- src/ReportBase/_ReportOptions.py | 10 +++------ src/plugins/AncestorChart.py | 6 +++--- src/plugins/AncestorReport.py | 6 +++--- src/plugins/BookReport.py | 30 +++++++++++++------------- src/plugins/CalculateEstimatedDates.py | 6 ++++-- src/plugins/Calendar.py | 15 ++++++------- src/plugins/CustomBookText.py | 6 +++--- src/plugins/DescendChart.py | 6 +++--- src/plugins/DescendReport.py | 6 +++--- src/plugins/DetAncestralReport.py | 6 +++--- src/plugins/DetDescendantReport.py | 6 +++--- src/plugins/EndOfLineReport.py | 6 +++--- src/plugins/FamilyGroup.py | 6 +++--- src/plugins/FanChart.py | 6 +++--- src/plugins/GVFamilyLines.py | 6 +++--- src/plugins/GVHourGlass.py | 6 +++--- src/plugins/GVRelGraph.py | 11 +++++----- src/plugins/IndivComplete.py | 11 +++++----- src/plugins/KinshipReport.py | 6 +++--- src/plugins/MarkerReport.py | 9 ++++---- src/plugins/StatisticsChart.py | 11 +++++----- src/plugins/TimeLine.py | 13 ++++++----- 25 files changed, 126 insertions(+), 104 deletions(-) diff --git a/ChangeLog b/ChangeLog index a88655259..470b5eccb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2008-01-24 Brian Matherly + * src/ReportBase/_CommandLineReport.py: + * src/ReportBase/_ReportOptions.py: + * src/plugins/DescendReport.py: + * src/plugins/DetDescendantReport.py: + * src/plugins/KinshipReport.py: + * src/plugins/IndivComplete.py: + * src/plugins/CalculateEstimatedDates.py: + * src/plugins/BookReport.py: + * src/plugins/TimeLine.py: + * src/plugins/Calendar.py: + * src/plugins/GVFamilyLines.py: + * src/plugins/AncestorReport.py: + * src/plugins/MarkerReport.py: + * src/plugins/DescendChart.py: + * src/plugins/EndOfLineReport.py: + * src/plugins/AncestorChart.py: + * src/plugins/DetAncestralReport.py: + * src/plugins/CustomBookText.py: + * src/plugins/FamilyGroup.py: + * src/plugins/GVRelGraph.py: + * src/plugins/GVHourGlass.py: + * src/plugins/StatisticsChart.py: + * src/plugins/FanChart.py: + * src/PluginUtils/_GuiOptions.py: + Refactoring the report system: reports no longer require dbstate. + 2008-01-23 Gary Burton * src/plugins/GVFamilyLines.py: Use fallback events e.g. baptism/burial when no birth or death events are available. diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index 9920a29f1..74edc3642 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# $Id: $ +# $Id$ """ Specific option handling for a GUI. @@ -861,7 +861,7 @@ class GuiMenuOptions: self.options_dict = {} self.options_help = {} self.__tooltips = gtk.Tooltips() - self.add_menu_options(self.menu, dbstate) + self.add_menu_options(self.menu) for name in self.menu.get_all_option_names(): option = self.menu.get_option_by_name(name) self.options_dict[name] = option.get_value() @@ -873,7 +873,7 @@ class GuiMenuOptions: """ pass - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): """ Add the user defined options to the menu. diff --git a/src/ReportBase/_CommandLineReport.py b/src/ReportBase/_CommandLineReport.py index ab1bb86a8..62ba9f58d 100644 --- a/src/ReportBase/_CommandLineReport.py +++ b/src/ReportBase/_CommandLineReport.py @@ -48,7 +48,8 @@ class CommandLineReport: noopt=False): self.database = database self.category = category - self.option_class = option_class(name) + self.option_class = option_class(name, database) + self.option_class.load_previous_values() self.show = options_str_dict.pop('show',None) self.options_str_dict = options_str_dict self.init_options(noopt) diff --git a/src/ReportBase/_ReportOptions.py b/src/ReportBase/_ReportOptions.py index fac9e423f..84e6f2d44 100644 --- a/src/ReportBase/_ReportOptions.py +++ b/src/ReportBase/_ReportOptions.py @@ -782,13 +782,9 @@ class MenuReportOptions(GuiMenuOptions,ReportOptions): MenuReportOptions class will worry about setting up the GUI. """ - def __init__(self,name,dbstate=None): - if dbstate: - active_person = dbstate.get_active_person().get_gramps_id() - else: - active_person = None - ReportOptions.__init__(self,name,active_person) - GuiMenuOptions.__init__(self,dbstate) + def __init__(self, name, dbase): + ReportOptions.__init__(self, name, None) + GuiMenuOptions.__init__(self, dbase) def load_previous_values(self): ReportOptions.load_previous_values(self) diff --git a/src/plugins/AncestorChart.py b/src/plugins/AncestorChart.py index 34da091b4..9bc383ee6 100644 --- a/src/plugins/AncestorChart.py +++ b/src/plugins/AncestorChart.py @@ -450,10 +450,10 @@ class AncestorChartOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): category_name = _("Report Options") diff --git a/src/plugins/AncestorReport.py b/src/plugins/AncestorReport.py index d8d77fba7..ff879899d 100644 --- a/src/plugins/AncestorReport.py +++ b/src/plugins/AncestorReport.py @@ -236,10 +236,10 @@ class AncestorOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self, name, dbstate=None): - MenuReportOptions.__init__(self, name, dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the ancestor report. """ diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index f1521e4f6..6a99f7437 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -177,14 +177,14 @@ class BookItem: Interface into the book item -- a smallest element of the book. """ - def __init__(self, dbstate, name=None): + def __init__(self, dbase, name=None): """ Creates a new empty BookItem. name: if not None then the book item is retreived from the book item registry using name for lookup """ - self.dbstate = dbstate + self.dbase = dbase if name: self.get_registered_item(name) else: @@ -222,7 +222,7 @@ class BookItem: self.category = item[1] self.write_item = item[2] self.name = item[4] - self.option_class = item[3](self.name, self.dbstate) + self.option_class = item[3](self.name, self.dbase) self.option_class.load_previous_values() def get_name(self): @@ -394,14 +394,14 @@ class BookList: BookList is loaded from a specified XML file if it exists. """ - def __init__(self, filename, dbstate): + def __init__(self, filename, dbase): """ Creates a new BookList from the books that may be defined in the specified file. file: XML file that contains book items definitions """ - self.dbstate = dbstate + self.dbase = dbase self.bookmap = {} self.file = os.path.join(const.HOME_DIR, filename) self.parse() @@ -487,7 +487,7 @@ class BookList: """ try: p = make_parser() - p.setContentHandler(BookParser(self, self.dbstate)) + p.setContentHandler(BookParser(self, self.dbase)) the_file = open(self.file) p.parse(the_file) the_file.close() @@ -505,14 +505,14 @@ class BookParser(handler.ContentHandler): SAX parsing class for the Books XML file. """ - def __init__(self, booklist, dbstate): + def __init__(self, booklist, dbase): """ Creates a BookParser class that populates the passed booklist. booklist: BookList to be loaded from the file. """ handler.ContentHandler.__init__(self) - self.dbstate = dbstate + self.dbase = dbase self.booklist = booklist self.b = None self.i = None @@ -535,7 +535,7 @@ class BookParser(handler.ContentHandler): self.dbname = attrs['database'] self.b.set_dbname(self.dbname) elif tag == "item": - self.i = BookItem(self.dbstate, attrs['name']) + self.i = BookItem(self.dbase, attrs['name']) self.o = {} elif tag == "option": self.an_o_name = attrs['name'] @@ -809,7 +809,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow): self.bk_model.clear() for saved_item in book.get_item_list(): name = saved_item.get_name() - item = BookItem(self.dbstate, name) + item = BookItem(self.dbase, name) item.option_class = saved_item.option_class _initialize_options(item.option_class, self.dbstate) item.set_style_name(saved_item.get_style_name()) @@ -831,7 +831,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow): if not the_iter: return data = self.av_model.get_data(the_iter, range(self.av_ncols)) - item = BookItem(self.dbstate, data[2]) + item = BookItem(self.db, data[2]) _initialize_options(item.option_class, self.dbstate) data[2] = _get_subject(item.option_class, self.db) self.bk_model.add(data) @@ -993,7 +993,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow): """ Save the current book in the xml booklist file. """ - self.book_list = BookList(self.file, self.dbstate) + self.book_list = BookList(self.file, self.db) name = unicode(self.name_entry.get_text()) self.book.set_name(name) self.book.set_dbname(self.db.get_save_path()) @@ -1004,7 +1004,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow): """ Run the BookListDisplay dialog to present the choice of books to open. """ - self.book_list = BookList(self.file, self.dbstate) + self.book_list = BookList(self.file, self.db) booklistdisplay = BookListDisplay(self.book_list, 1, 0) booklistdisplay.top.destroy() book = booklistdisplay.selection @@ -1016,7 +1016,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow): """ Run the BookListDisplay dialog to present the choice of books to delete. """ - self.book_list = BookList(self.file, self.dbstate) + self.book_list = BookList(self.file, self.db) booklistdisplay = BookListDisplay(self.book_list, 0, 1) booklistdisplay.top.destroy() @@ -1180,7 +1180,7 @@ def cl_report(database, name, category, options_str_dict): if clr.show: return - book_list = BookList('books.xml', None) + book_list = BookList('books.xml', database) book_name = clr.options_dict['bookname'] book = book_list.get_book(book_name) selected_style = BaseDoc.StyleSheet() diff --git a/src/plugins/CalculateEstimatedDates.py b/src/plugins/CalculateEstimatedDates.py index 98fb1ac88..b10096f26 100644 --- a/src/plugins/CalculateEstimatedDates.py +++ b/src/plugins/CalculateEstimatedDates.py @@ -52,9 +52,11 @@ from ReportBase import ReportUtils #------------------------------------------------------------------------ class CalcEstDateOptions(MenuToolOptions): """ Calculate Estimated Date options """ - - def add_menu_options(self, menu, dbstate): + def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() + MenuToolOptions.__init__(self, name, person_id, dbstate) + + def add_menu_options(self, menu): """ Adds the options """ category_name = _("Options") diff --git a/src/plugins/Calendar.py b/src/plugins/Calendar.py index 3d205dfd6..3925b0c88 100644 --- a/src/plugins/Calendar.py +++ b/src/plugins/Calendar.py @@ -475,13 +475,13 @@ class CalendarReport(Calendar): class CalendarOptions(MenuReportOptions): """ Calendar options for graphic calendar """ - def __init__(self, name, dbstate=None): - self.__dbstate = dbstate + def __init__(self, name, dbase): + self.__db = dbase self.__pid = None self.__filter = None - MenuReportOptions.__init__(self, name, dbstate) + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): """ Adds the options for the graphical calendar """ category_name = _("Report Options") @@ -561,9 +561,8 @@ class CalendarOptions(MenuReportOptions): """ Update the filter list based on the selected person """ - _db = self.__dbstate.get_database() gid = self.__pid.get_value() - person = _db.get_person_from_gramps_id(gid) + person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) @@ -648,14 +647,14 @@ class CalendarReportOptions(CalendarOptions): def __init__(self, name, dbstate=None): CalendarOptions.__init__(self, name, dbstate) - def add_menu_options(self, menu,dbstate): + def add_menu_options(self, menu): """ Adds the options for the graphical calendar """ category_name = _("Text Options") titletext = StringOption(_("Title text"), _("Birthday and Anniversary Report")) titletext.set_help(_("Title of calendar")) menu.add_option(category_name,"titletext", titletext) - CalendarOptions.add_menu_options(self, menu, dbstate) + CalendarOptions.add_menu_options(self, menu) category_name = _("Report Options") option = BooleanOption(_("Include relationships to center person (slower)"), False) diff --git a/src/plugins/CustomBookText.py b/src/plugins/CustomBookText.py index bb74ba8ad..57d1c4662 100644 --- a/src/plugins/CustomBookText.py +++ b/src/plugins/CustomBookText.py @@ -106,10 +106,10 @@ class CustomTextOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): category_name = _("Text") diff --git a/src/plugins/DescendChart.py b/src/plugins/DescendChart.py index 0964e82d5..a1b9f5a01 100644 --- a/src/plugins/DescendChart.py +++ b/src/plugins/DescendChart.py @@ -403,10 +403,10 @@ class DescendChartOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the descendant report. """ diff --git a/src/plugins/DescendReport.py b/src/plugins/DescendReport.py index bbf1a2809..f6d4be3ba 100644 --- a/src/plugins/DescendReport.py +++ b/src/plugins/DescendReport.py @@ -188,10 +188,10 @@ class DescendantOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): category_name = _("Report Options") pid = PersonOption(_("Center Person")) diff --git a/src/plugins/DetAncestralReport.py b/src/plugins/DetAncestralReport.py index 3a075a75f..4d75aa5db 100644 --- a/src/plugins/DetAncestralReport.py +++ b/src/plugins/DetAncestralReport.py @@ -671,10 +671,10 @@ class DetAncestorOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): category_name = _("Report Options") pid = PersonOption(_("Center Person")) diff --git a/src/plugins/DetDescendantReport.py b/src/plugins/DetDescendantReport.py index c3a3989d1..83203e9ed 100644 --- a/src/plugins/DetDescendantReport.py +++ b/src/plugins/DetDescendantReport.py @@ -629,10 +629,10 @@ class DetDescendantOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the detailed descendant report. """ diff --git a/src/plugins/EndOfLineReport.py b/src/plugins/EndOfLineReport.py index 43f8bc7c1..1dddd51e1 100644 --- a/src/plugins/EndOfLineReport.py +++ b/src/plugins/EndOfLineReport.py @@ -222,10 +222,10 @@ class EndOfLineOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self, name, dbstate=None): - MenuReportOptions.__init__(self, name, dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the End of Line report. """ diff --git a/src/plugins/FamilyGroup.py b/src/plugins/FamilyGroup.py index 79e8eaa47..7cd66a36a 100644 --- a/src/plugins/FamilyGroup.py +++ b/src/plugins/FamilyGroup.py @@ -574,10 +574,10 @@ class FamilyGroupOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): ########################## category_name = _("Report Options") diff --git a/src/plugins/FanChart.py b/src/plugins/FanChart.py index d69cfba40..330e32d3d 100644 --- a/src/plugins/FanChart.py +++ b/src/plugins/FanChart.py @@ -318,12 +318,12 @@ class FanChart(Report): #------------------------------------------------------------------------ class FanChartOptions(MenuReportOptions): - def __init__(self,name,dbstate=None): + def __init__(self, name, dbase): self.MAX_GENERATIONS = 8 - MenuReportOptions.__init__(self,name,dbstate) + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the fan chart. """ diff --git a/src/plugins/GVFamilyLines.py b/src/plugins/GVFamilyLines.py index 6492c2f45..83fa2516f 100644 --- a/src/plugins/GVFamilyLines.py +++ b/src/plugins/GVFamilyLines.py @@ -80,10 +80,10 @@ class FamilyLinesOptions(MenuReportOptions): Defines all of the controls necessary to configure the FamilyLines reports. """ - def __init__(self, name, dbstate=None): - MenuReportOptions.__init__(self, name, dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu,dbstate): + def add_menu_options(self, menu): # -------------------------------- category = _('People of Interest') diff --git a/src/plugins/GVHourGlass.py b/src/plugins/GVHourGlass.py index 2ed13a92c..1dac24b92 100644 --- a/src/plugins/GVHourGlass.py +++ b/src/plugins/GVHourGlass.py @@ -164,10 +164,10 @@ class HourGlassOptions(MenuReportOptions): """ Defines options for the HourGlass report. """ - def __init__(self, name, dbstate=None): - MenuReportOptions.__init__(self, name, dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): """ Create all the menu options for this report. """ diff --git a/src/plugins/GVRelGraph.py b/src/plugins/GVRelGraph.py index fb59863c8..fbfc3cdca 100644 --- a/src/plugins/GVRelGraph.py +++ b/src/plugins/GVRelGraph.py @@ -415,15 +415,15 @@ class RelGraphOptions(MenuReportOptions): """ Defines options and provides handling interface. """ - def __init__(self, name, dbstate=None): + def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__include_images = None self.__image_on_side = None - self.__dbstate = dbstate - MenuReportOptions.__init__(self, name, dbstate) + self.__db = dbase + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): ################################ category_name = _("Report Options") ################################ @@ -519,9 +519,8 @@ class RelGraphOptions(MenuReportOptions): """ Update the filter list based on the selected person """ - _db = self.__dbstate.get_database() gid = self.__pid.get_value() - person = _db.get_person_from_gramps_id(gid) + person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) diff --git a/src/plugins/IndivComplete.py b/src/plugins/IndivComplete.py index 9cf98e0fe..68b2cb5a7 100644 --- a/src/plugins/IndivComplete.py +++ b/src/plugins/IndivComplete.py @@ -501,13 +501,13 @@ class IndivCompleteOptions(MenuReportOptions): """ Defines options and provides handling interface. """ - def __init__(self, name, dbstate=None): - self.__dbstate = dbstate + def __init__(self, name, dbase): + self.__db = dbase self.__pid = None self.__filter = None - MenuReportOptions.__init__(self, name, dbstate) + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): ################################ category_name = _("Report Options") ################################ @@ -533,9 +533,8 @@ class IndivCompleteOptions(MenuReportOptions): """ Update the filter list based on the selected person """ - _db = self.__dbstate.get_database() gid = self.__pid.get_value() - person = _db.get_person_from_gramps_id(gid) + person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, True) self.__filter.set_filters(filter_list) diff --git a/src/plugins/KinshipReport.py b/src/plugins/KinshipReport.py index 97e3d04a9..bcc0806da 100644 --- a/src/plugins/KinshipReport.py +++ b/src/plugins/KinshipReport.py @@ -324,10 +324,10 @@ class KinshipOptions(MenuReportOptions): Defines options and provides handling interface. """ - def __init__(self, name, dbstate=None): - MenuReportOptions.__init__(self, name, dbstate) + def __init__(self, name, dbase): + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self, menu, dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the kinship report. """ diff --git a/src/plugins/MarkerReport.py b/src/plugins/MarkerReport.py index 462e45660..40f323228 100644 --- a/src/plugins/MarkerReport.py +++ b/src/plugins/MarkerReport.py @@ -425,10 +425,11 @@ class MarkerReport(Report): #------------------------------------------------------------------------ class MarkerOptions(MenuReportOptions): - def __init__(self,name,dbstate=None): - MenuReportOptions.__init__(self,name,dbstate) + def __init__(self, name, dbase): + self.__db = dbase + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the marker report. """ @@ -443,7 +444,7 @@ class MarkerOptions(MenuReportOptions): marker.add_item(MarkerType._I2EMAP[mtype], MarkerType._I2SMAP[mtype] ) # Add custom marker types - for m in dbstate.get_database().get_marker_types(): + for m in self.__db.get_marker_types(): marker.add_item( m, m ) marker.set_help( _("The marker to use for the report")) menu.add_option(category_name,"marker",marker) diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index c42db56ac..1088848ac 100644 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -659,13 +659,13 @@ class StatisticsChart(Report): #------------------------------------------------------------------------ class StatisticsChartOptions(MenuReportOptions): - def __init__(self,name,dbstate=None): + def __init__(self, name, dbase): self.__pid = None self.__filter = None - self.__dbstate = dbstate - MenuReportOptions.__init__(self, name, dbstate) + self.__db = dbase + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): """ Add options to the menu for the statistics report. """ @@ -752,9 +752,8 @@ class StatisticsChartOptions(MenuReportOptions): """ Update the filter list based on the selected person """ - _db = self.__dbstate.get_database() gid = self.__pid.get_value() - person = _db.get_person_from_gramps_id(gid) + person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index 5aa21aee9..7d9421aee 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -293,13 +293,13 @@ class TimeLine(Report): #------------------------------------------------------------------------ class TimeLineOptions(MenuReportOptions): - def __init__(self,name,dbstate=None): + def __init__(self, name, dbase): self.__pid = None self.__filter = None - self.__dbstate = dbstate - MenuReportOptions.__init__(self,name,dbstate) + self.__db = dbase + MenuReportOptions.__init__(self, name, dbase) - def add_menu_options(self,menu,dbstate): + def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) @@ -317,7 +317,7 @@ class TimeLineOptions(MenuReportOptions): sortby = EnumeratedListOption(_('Sort by'), 0 ) idx = 0 - for item in _get_sort_functions(Sort.Sort(dbstate.get_database())): + for item in _get_sort_functions(Sort.Sort(self.__db)): sortby.add_item(idx,item[0]) idx += 1 sortby.set_help( _("Sorting method to use")) @@ -327,9 +327,8 @@ class TimeLineOptions(MenuReportOptions): """ Update the filter list based on the selected person """ - _db = self.__dbstate.get_database() gid = self.__pid.get_value() - person = _db.get_person_from_gramps_id(gid) + person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list)