From 3cc07e26dd20dfab46c6ecb3d4d62e2fdcd197db Mon Sep 17 00:00:00 2001 From: Gary Burton Date: Mon, 7 Jul 2008 19:32:18 +0000 Subject: [PATCH] Apply referenced proxy to remove unused objects when a filter or one of the other proxies is applied. svn: r10846 --- src/GrampsDbUtils/_WriteGedcom.py | 7 +++++++ src/GrampsDbUtils/_WriteXML.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index a80becf6f..47f67a456 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -340,6 +341,12 @@ class GedcomWriter(BasicUtils.UpdateCallback): self.dbase = gen.proxy.FilterProxyDb( self.dbase, option_box.cfilter) + # Apply the ReferencedProxyDb to remove any objects not referenced + # after any of the other proxies have been applied + if option_box.private or option_box.restrict \ + or not option_box.cfilter.is_empty(): + self.dbase = gen.proxy.ReferencedProxyDb(self.dbase) + def write_gedcom_file(self, filename): """ Write the actual GEDCOM file to the specfied filename. diff --git a/src/GrampsDbUtils/_WriteXML.py b/src/GrampsDbUtils/_WriteXML.py index 49ae6ed66..d5843e248 100644 --- a/src/GrampsDbUtils/_WriteXML.py +++ b/src/GrampsDbUtils/_WriteXML.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -93,6 +94,12 @@ def export_data(database, filename, person, option_box, callback=None): if not option_box.cfilter.is_empty(): database = gen.proxy.FilterProxyDb(database, option_box.cfilter) + # Apply the ReferencedProxyDb to remove any objects not referenced + # after any of the other proxies have been applied + if option_box.private or option_box.restrict \ + or not option_box.cfilter.is_empty(): + database = gen.proxy.ReferencedProxyDb(database) + g = XmlWriter(database, callback, 0, compress) return g.write(filename)