From 654fb816655a773008a5cdf26b337fa32c9f0c71 Mon Sep 17 00:00:00 2001 From: Michiel Nauta Date: Thu, 19 May 2011 20:36:17 +0000 Subject: [PATCH] Change default to return handles unsorted on get_object_handles methods svn: r17537 --- src/Filters/SideBar/_SidebarFilter.py | 2 +- src/ToolTips.py | 2 +- src/cli/plug/__init__.py | 2 +- src/gen/db/base.py | 10 +++++----- src/gen/db/read.py | 10 +++++----- src/gen/proxy/filter.py | 2 +- src/gen/proxy/proxybase.py | 10 +++++----- src/gui/filtereditor.py | 1 + src/gui/views/tags.py | 2 +- src/plugins/export/ExportPkg.py | 2 +- src/plugins/gramplet/WhatsNext.py | 2 +- src/plugins/textreport/TagReport.py | 4 ++-- 12 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/Filters/SideBar/_SidebarFilter.py b/src/Filters/SideBar/_SidebarFilter.py index ddbad4e10..f5a102121 100644 --- a/src/Filters/SideBar/_SidebarFilter.py +++ b/src/Filters/SideBar/_SidebarFilter.py @@ -192,7 +192,7 @@ class SidebarFilter(DbGUIElement): Called when the tag list needs to be rebuilt. """ self.__tag_list = [] - for handle in self.dbstate.db.get_tag_handles(): + for handle in self.dbstate.db.get_tag_handles(sort_handles=True): tag = self.dbstate.db.get_tag_from_handle(handle) self.__tag_list.append((tag.get_name(), handle)) self.on_tags_changed([item[0] for item in self.__tag_list]) diff --git a/src/ToolTips.py b/src/ToolTips.py index 34a12e341..70b81f5c8 100644 --- a/src/ToolTips.py +++ b/src/ToolTips.py @@ -163,7 +163,7 @@ class RepositoryTip(object): # Get the list of sources that reference this repository repos_handle = self._obj.get_handle() source_list = [ src_handle for src_handle \ - in self._db.get_source_handles() \ + in self._db.get_source_handles(sort_handles=True) \ if self._db.get_source_from_handle(src_handle).has_repo_reference(repos_handle)] if len(source_list) > 0: diff --git a/src/cli/plug/__init__.py b/src/cli/plug/__init__.py index a4da4eedf..24d725a0d 100644 --- a/src/cli/plug/__init__.py +++ b/src/cli/plug/__init__.py @@ -249,7 +249,7 @@ class CommandLineReport(object): if isinstance(option, PersonOption): id_list = [] - for person_handle in self.database.get_person_handles(): + for person_handle in self.database.get_person_handles(True): person = self.database.get_person_from_handle(person_handle) id_list.append("%s\t%s" % ( person.get_gramps_id(), diff --git a/src/gen/db/base.py b/src/gen/db/base.py index be8abc207..bb72e74bb 100644 --- a/src/gen/db/base.py +++ b/src/gen/db/base.py @@ -323,7 +323,7 @@ class DbReadBase(object): """ raise NotImplementedError - def get_media_object_handles(self, sort_handles=True): + def get_media_object_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each MediaObject in the database. @@ -515,7 +515,7 @@ class DbReadBase(object): """ raise NotImplementedError - def get_person_handles(self, sort_handles=True): + def get_person_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Person in the database. @@ -553,7 +553,7 @@ class DbReadBase(object): """ raise NotImplementedError - def get_place_handles(self, sort_handles=True): + def get_place_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Place in the database. @@ -719,7 +719,7 @@ class DbReadBase(object): """ raise NotImplementedError - def get_source_handles(self, sort_handles=True): + def get_source_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Source in the database. @@ -764,7 +764,7 @@ class DbReadBase(object): """ raise NotImplementedError - def get_tag_handles(self, sort_handles=True): + def get_tag_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Tag in the database. diff --git a/src/gen/db/read.py b/src/gen/db/read.py index 3fa8497c2..00fae90f9 100644 --- a/src/gen/db/read.py +++ b/src/gen/db/read.py @@ -856,7 +856,7 @@ class DbBsddbRead(DbReadBase, Callback): def all_handles(self, table): return table.keys(txn=self.txn) - def get_person_handles(self, sort_handles=True): + def get_person_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Person in the database. @@ -870,7 +870,7 @@ class DbBsddbRead(DbReadBase, Callback): return handle_list return [] - def get_place_handles(self, sort_handles=True): + def get_place_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Place in the database. @@ -885,7 +885,7 @@ class DbBsddbRead(DbReadBase, Callback): return handle_list return [] - def get_source_handles(self, sort_handles=True): + def get_source_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Source in the database. @@ -899,7 +899,7 @@ class DbBsddbRead(DbReadBase, Callback): return handle_list return [] - def get_media_object_handles(self, sort_handles=True): + def get_media_object_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each MediaObject in the database. @@ -949,7 +949,7 @@ class DbBsddbRead(DbReadBase, Callback): return self.all_handles(self.note_map) return [] - def get_tag_handles(self, sort_handles=True): + def get_tag_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Tag in the database. diff --git a/src/gen/proxy/filter.py b/src/gen/proxy/filter.py index 6e1192985..baa9ac783 100644 --- a/src/gen/proxy/filter.py +++ b/src/gen/proxy/filter.py @@ -302,7 +302,7 @@ class FilterProxyDb(ProxyDbBase): if note: return self.get_note_from_handle(note.get_handle()) - def get_person_handles(self, sort_handles=True): + def get_person_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Person in the database. If sort_handles is True, the list is sorted by surnames diff --git a/src/gen/proxy/proxybase.py b/src/gen/proxy/proxybase.py index e43269c11..0bc945a60 100644 --- a/src/gen/proxy/proxybase.py +++ b/src/gen/proxy/proxybase.py @@ -102,7 +102,7 @@ class ProxyDbBase(DbReadBase): include_tag = \ None - def get_person_handles(self, sort_handles=True): + def get_person_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Person in the database. @@ -132,7 +132,7 @@ class ProxyDbBase(DbReadBase): else: return [] - def get_source_handles(self, sort_handles=True): + def get_source_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Source in the database. @@ -142,7 +142,7 @@ class ProxyDbBase(DbReadBase): else: return [] - def get_place_handles(self, sort_handles=True): + def get_place_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Place in the database. @@ -152,7 +152,7 @@ class ProxyDbBase(DbReadBase): else: return [] - def get_media_object_handles(self, sort_handles=True): + def get_media_object_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each MediaObject in the database. @@ -182,7 +182,7 @@ class ProxyDbBase(DbReadBase): else: return [] - def get_tag_handles(self, sort_handles=True): + def get_tag_handles(self, sort_handles=False): """ Return a list of database handles, one handle for each Tag in the database. diff --git a/src/gui/filtereditor.py b/src/gui/filtereditor.py index 6886cdf7d..f8f3662d2 100644 --- a/src/gui/filtereditor.py +++ b/src/gui/filtereditor.py @@ -1122,6 +1122,7 @@ class FilterEditor(ManagedWindow.ManagedWindow): filter_set.add(gfilter) def get_all_handles(self): + # Why use iter for some and get for others? if self.namespace == 'Person': return self.db.iter_person_handles() elif self.namespace == 'Family': diff --git a/src/gui/views/tags.py b/src/gui/views/tags.py index 533323cff..00ee61c04 100644 --- a/src/gui/views/tags.py +++ b/src/gui/views/tags.py @@ -179,7 +179,7 @@ class Tags(DbGUIElement): Called when the tag list needs to be rebuilt. """ self.__tag_list = [] - for handle in self.db.get_tag_handles(): + for handle in self.db.get_tag_handles(sort_handles=True): tag = self.db.get_tag_from_handle(handle) self.__tag_list.append((tag.get_name(), tag.get_handle())) self.update_tag_menu() diff --git a/src/plugins/export/ExportPkg.py b/src/plugins/export/ExportPkg.py index 1704f94c4..2b333c222 100644 --- a/src/plugins/export/ExportPkg.py +++ b/src/plugins/export/ExportPkg.py @@ -180,7 +180,7 @@ class PackageWriter(object): # Write media files first, since the database may be modified # during the process (i.e. when removing object) - for m_id in self.db.get_media_object_handles(): + for m_id in self.db.get_media_object_handles(sort_handles=True): mobject = self.db.get_object_from_handle(m_id) filename = Utils.media_path_full(self.db, mobject.get_path()) archname = str(mobject.get_path()) diff --git a/src/plugins/gramplet/WhatsNext.py b/src/plugins/gramplet/WhatsNext.py index 3c91e4331..65928ec9a 100644 --- a/src/plugins/gramplet/WhatsNext.py +++ b/src/plugins/gramplet/WhatsNext.py @@ -94,7 +94,7 @@ class WhatNextGramplet(Gramplet): self.opts[3].add_item('', '') self.opts[4].add_item('', '') self.opts[5].add_item('', '') - for tag_handle in self.dbstate.db.get_tag_handles(): + for tag_handle in self.dbstate.db.get_tag_handles(sort_handles=True): tag = self.dbstate.db.get_tag_from_handle(tag_handle) tag_name = tag.get_name() self.opts[3].add_item(tag_name, tag_name) diff --git a/src/plugins/textreport/TagReport.py b/src/plugins/textreport/TagReport.py index 1535153c2..0eddb55ba 100644 --- a/src/plugins/textreport/TagReport.py +++ b/src/plugins/textreport/TagReport.py @@ -426,7 +426,7 @@ class TagReport(Report): self.doc.end_table() def write_media(self): - mlist = self.database.get_media_object_handles() + mlist = self.database.get_media_object_handles(sort_handles=True) FilterClass = GenericFilterFactory('MediaObject') filter = FilterClass() filter.add_rule(Rules.MediaObject.HasTag([self.tag])) @@ -526,7 +526,7 @@ class TagOptions(MenuReportOptions): category_name = _("Report Options") all_tags = [] - for handle in self.__db.get_tag_handles(): + for handle in self.__db.get_tag_handles(sort_handles=True): tag = self.__db.get_tag_from_handle(handle) all_tags.append(tag.get_name())