In .:
2006-12-01 Alex Roitman <shura@gramps-project.org> * src/plugins/Makefile.am (pkgdata_PYTHON): Ship new file. * src/plugins/RebuildRefMap.py: Add new plugin. * src/GrampsDb/_GrampsBSDDB.py (reindex_reference_map): Fix reindexing. * src/GrampsDb/_GrampsDbBase.py (reindex_reference_map): Add a placeholder method for anything other than BSDDB. In po: 2006-12-01 Alex Roitman <shura@gramps-project.org> * POTFILES.in: List new file. svn: r7740
This commit is contained in:
parent
abeb0de15b
commit
685c655b80
@ -1,3 +1,10 @@
|
||||
2006-12-01 Alex Roitman <shura@gramps-project.org>
|
||||
* src/plugins/Makefile.am (pkgdata_PYTHON): Ship new file.
|
||||
* src/plugins/RebuildRefMap.py: Add new plugin.
|
||||
* src/GrampsDb/_GrampsBSDDB.py (reindex_reference_map): Fix reindexing.
|
||||
* src/GrampsDb/_GrampsDbBase.py (reindex_reference_map): Add a
|
||||
placeholder method for anything other than BSDDB.
|
||||
|
||||
2006-11-30 A Costa <agcosta@gis.net>
|
||||
* data/man/gramps.1.in: Typos.
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
2006-12-01 Alex Roitman <shura@gramps-project.org>
|
||||
* POTFILES.in: List new file.
|
||||
|
||||
2006-11-30 Alex Roitman <shura@gramps-project.org>
|
||||
* POTFILES.in: List new files.
|
||||
|
||||
|
@ -313,6 +313,7 @@ src/plugins/WriteCD.py
|
||||
src/plugins/WriteFtree.py
|
||||
src/plugins/WriteGeneWeb.py
|
||||
src/plugins/WritePkg.py
|
||||
src/plugins/RebuildRefMap.py
|
||||
|
||||
# PluginUtils package
|
||||
src/PluginUtils/__init__.py
|
||||
|
@ -870,17 +870,34 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
||||
Reindex all primary records in the database.
|
||||
This will be a slow process for large databases.
|
||||
|
||||
At present this method does not clear the reference_map before it
|
||||
reindexes. This is fine when if reindex is run to index new content
|
||||
or when upgrading from a non-reference_map version of the database.
|
||||
But it might be a problem if reindex is used to repair a broken index
|
||||
because any references to primary objects that are no longer in the
|
||||
database will remain in the reference_map index.
|
||||
|
||||
So if you want to reindex for repair purposes you need to
|
||||
clear the reference_map first.
|
||||
"""
|
||||
|
||||
# First, remove the reference map and related tables
|
||||
self.reference_map_referenced_map.close()
|
||||
junk = db.DB(self.env)
|
||||
junk.remove(self.full_name,"reference_map_referenced_map")
|
||||
|
||||
self.reference_map_primary_map.close()
|
||||
junk = db.DB(self.env)
|
||||
junk.remove(self.full_name,"reference_map_primary_map")
|
||||
|
||||
self.reference_map.close()
|
||||
junk = db.DB(self.env)
|
||||
junk.remove(self.full_name,"reference_map")
|
||||
|
||||
# Open reference_map and primapry map
|
||||
self.reference_map = self.open_table(self.full_name, "reference_map",
|
||||
dbtype=db.DB_BTREE)
|
||||
|
||||
open_flags = self.open_flags()
|
||||
self.reference_map_primary_map = db.DB(self.env)
|
||||
self.reference_map_primary_map.set_flags(db.DB_DUP)
|
||||
self.reference_map_primary_map.open(self.full_name,
|
||||
"reference_map_primary_map",
|
||||
db.DB_BTREE, flags=open_flags)
|
||||
self.reference_map.associate(self.reference_map_primary_map,
|
||||
find_primary_handle,
|
||||
open_flags)
|
||||
|
||||
# Make a dictionary of the functions and classes that we need for
|
||||
# each of the primary object tables.
|
||||
@ -901,6 +918,8 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
||||
'class_func': Repository},
|
||||
}
|
||||
|
||||
transaction = self.transaction_begin(batch=True,no_magic=True)
|
||||
|
||||
# Now we use the functions and classes defined above
|
||||
# to loop through each of the primary object tables.
|
||||
for primary_table_name in primary_tables.keys():
|
||||
@ -911,17 +930,33 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
||||
# Grab the real object class here so that the lookup does
|
||||
# not happen inside the cursor loop.
|
||||
class_func = primary_tables[primary_table_name]['class_func']
|
||||
|
||||
while data:
|
||||
found_handle,val = data
|
||||
obj = class_func()
|
||||
obj.unserialize(val)
|
||||
|
||||
self._update_reference_map(obj,transaction)
|
||||
if self.UseTXN:
|
||||
the_txn = self.env.txn_begin()
|
||||
else:
|
||||
the_txn = None
|
||||
self._update_reference_map(obj,transaction,the_txn)
|
||||
if not self.UseTXN:
|
||||
data_map.sync()
|
||||
if the_txn:
|
||||
the_txn.commit()
|
||||
|
||||
data = cursor.next()
|
||||
|
||||
cursor.close()
|
||||
self.transaction_commit(transaction,_("Rebuild reference map"))
|
||||
|
||||
self.reference_map_referenced_map = db.DB(self.env)
|
||||
self.reference_map_referenced_map.set_flags(db.DB_DUP|db.DB_DUPSORT)
|
||||
self.reference_map_referenced_map.open(
|
||||
self.full_name,"reference_map_referenced_map",
|
||||
db.DB_BTREE,flags=open_flags)
|
||||
self.reference_map.associate(self.reference_map_referenced_map,
|
||||
find_referenced_handle,open_flags)
|
||||
|
||||
return
|
||||
|
||||
|
@ -2044,6 +2044,13 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
need to be changed."""
|
||||
pass
|
||||
|
||||
def reindex_reference_map(self):
|
||||
"""
|
||||
Reindex all primary records in the database.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def find_backlink_handles(self, handle, include_classes=None):
|
||||
"""
|
||||
Find all objects that hold a reference to the object handle.
|
||||
|
@ -63,7 +63,8 @@ pkgdata_PYTHON = \
|
||||
Checkpoint.py\
|
||||
MediaManager.py\
|
||||
RemoveUnused.py\
|
||||
rel_pl.py
|
||||
rel_pl.py\
|
||||
RebuildRefMap.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/plugins
|
||||
pkgpythondir = @pkgpythondir@/plugins
|
||||
|
117
src/plugins/RebuildRefMap.py
Normal file
117
src/plugins/RebuildRefMap.py
Normal file
@ -0,0 +1,117 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
# Written by Alex Roitman
|
||||
|
||||
"Rebuild reference map tables"
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import cStringIO
|
||||
from gettext import gettext as _
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import logging
|
||||
log = logging.getLogger(".RebuildRefMap")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gtk modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import RelLib
|
||||
import Utils
|
||||
import const
|
||||
from PluginUtils import Tool, register_tool
|
||||
from QuestionDialog import OkDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# runTool
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RebuildRefMap(Tool.Tool):
|
||||
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
|
||||
Tool.Tool.__init__(self, dbstate, options_class, name)
|
||||
|
||||
if self.db.readonly:
|
||||
return
|
||||
|
||||
self.db.disable_signals()
|
||||
if uistate:
|
||||
self.db.reindex_reference_map()
|
||||
OkDialog(_("Reference maps rebuilt"),
|
||||
_('All reference maps have been rebuilt.'))
|
||||
else:
|
||||
print "Rebuilding reference maps..."
|
||||
self.db.reindex_reference_map()
|
||||
print "All reference maps have been rebuilt."
|
||||
self.db.enable_signals()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class RebuildRefMapOptions(Tool.ToolOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
Tool.ToolOptions.__init__(self,name,person_id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
register_tool(
|
||||
name = 'rebuild_refmap',
|
||||
category = Tool.TOOL_DBFIX,
|
||||
tool_class = RebuildRefMap,
|
||||
options_class = RebuildRefMapOptions,
|
||||
modes = Tool.MODE_GUI | Tool.MODE_CLI,
|
||||
translated_name = _("Rebuild reference map"),
|
||||
status=(_("Stable")),
|
||||
author_name = "Alex Roitman",
|
||||
author_email = "shura@gramps-project.org",
|
||||
description=_("Rebuilds reference map")
|
||||
)
|
Loading…
Reference in New Issue
Block a user