From ab3dfe14156d62a1cde726c3118dd7f5e3102777 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Wed, 23 Dec 2009 15:55:58 +0000 Subject: [PATCH] 3465: Create a new hierarchy of base classes for gramps cor databases (read, write) and add methods svn: r13894 --- src/DbState.py | 10 +- src/ReportBase/_CommandLineReport.py | 2 +- src/ReportBase/_Endnotes.py | 2 +- src/Simple/_SimpleAccess.py | 2 +- src/cli/arghandler.py | 2 +- src/cli/grampscli.py | 8 +- src/gen/db/backup.py | 22 +- src/gen/db/base.py | 2885 +++++++++++---------- src/gen/db/dbconst.py | 2 +- src/gen/db/exceptions.py | 10 +- src/gen/db/iterator.py | 2 +- src/gen/db/read.py | 94 +- src/gen/db/test/db_test.py | 268 ++ src/gen/db/txn.py | 12 +- src/gen/db/undoredo.py | 18 +- src/gen/db/write.py | 42 +- src/gen/proxy/private.py | 40 +- src/gen/proxy/proxybase.py | 34 +- src/gen/utils/callman.py | 4 +- src/gui/dbloader.py | 6 +- src/gui/dbman.py | 12 +- src/gui/viewmanager.py | 4 +- src/plugins/drawreport/StatisticsChart.py | 2 +- src/plugins/export/ExportXml.py | 18 +- src/plugins/import/ImportGrdb.py | 24 +- src/plugins/import/ImportXml.py | 6 +- src/plugins/lib/libgrdb.py | 26 +- src/plugins/lib/libmixin.py | 12 +- src/plugins/lib/libnarrate.py | 2 +- src/plugins/tool/Check.py | 6 +- src/web/djangodb.py | 6 +- 31 files changed, 1890 insertions(+), 1693 deletions(-) create mode 100644 src/gen/db/test/db_test.py diff --git a/src/DbState.py b/src/DbState.py index 924266bad..08c4e5c0d 100644 --- a/src/DbState.py +++ b/src/DbState.py @@ -22,7 +22,7 @@ Provide the database state class """ -from gen.db import GrampsDbRead +from gen.db import DbBsddbRead from gen.utils import Callback import config @@ -32,18 +32,18 @@ class DbState(Callback): """ __signals__ = { - 'database-changed' : (GrampsDbRead, ), + 'database-changed' : (DbBsddbRead, ), 'active-changed' : (str, ), 'no-database' : None, } def __init__(self): """ - Initalize the state with an empty (and useless) GrampsDbRead. This is + Initalize the state with an empty (and useless) DbBsddbRead. This is just a place holder until a real DB is assigned. """ Callback.__init__(self) - self.db = GrampsDbRead() + self.db = DbBsddbRead() self.open = False self.active = None self.sighndl = None @@ -115,7 +115,7 @@ class DbState(Callback): Closes the database without a new database """ self.db.close() - self.db = GrampsDbRead() + self.db = DbBsddbRead() self.db.db_is_open = False self.active = None self.open = False diff --git a/src/ReportBase/_CommandLineReport.py b/src/ReportBase/_CommandLineReport.py index 72abacce6..7d20d214a 100644 --- a/src/ReportBase/_CommandLineReport.py +++ b/src/ReportBase/_CommandLineReport.py @@ -443,7 +443,7 @@ def run_report(db, name, **options_str_dict): """ Given a database, run a given report. - db is a GrampsDb database + db is a Db database name is the name of a report diff --git a/src/ReportBase/_Endnotes.py b/src/ReportBase/_Endnotes.py index aa31881f0..445585482 100644 --- a/src/ReportBase/_Endnotes.py +++ b/src/ReportBase/_Endnotes.py @@ -93,7 +93,7 @@ def write_endnotes(bibliography, database, doc, printnotes=False): @param bibliography: The bibliography that contains the citations. @type bibliography: L{Bibliography} @param database: The database that the sources come from. - @type database: GrampsDbBase + @type database: DbBase @param doc: The document to write the endnotes into. @type doc: L{docgen.TextDoc} @param printnotes: Indicate if the notes attached to a source must be diff --git a/src/Simple/_SimpleAccess.py b/src/Simple/_SimpleAccess.py index ba9de8a9b..c47acd21b 100644 --- a/src/Simple/_SimpleAccess.py +++ b/src/Simple/_SimpleAccess.py @@ -114,7 +114,7 @@ class SimpleAccess(object): Initialize the SimpleAccess object with the database that will be used. @param dbase: GRAMPS database object - @type dbase: GrampsDbBase + @type dbase: DbBase """ self.dbase = dbase diff --git a/src/cli/arghandler.py b/src/cli/arghandler.py index c00facf44..f7283d017 100644 --- a/src/cli/arghandler.py +++ b/src/cli/arghandler.py @@ -344,7 +344,7 @@ class ArgHandler(object): else: self.imp_db_path = Utils.get_empty_tempdir("import_dbdir") - newdb = gen.db.GrampsDBDir() + newdb = gen.db.DbBsddb() newdb.write_version(self.imp_db_path) try: diff --git a/src/cli/grampscli.py b/src/cli/grampscli.py index e85f799ea..f6c42a3b8 100644 --- a/src/cli/grampscli.py +++ b/src/cli/grampscli.py @@ -50,7 +50,7 @@ import config import const import Errors import DbState -from gen.db import GrampsDBDir +from gen.db import DbBsddb import gen.db.exceptions from gen.plug import BasePluginManager from Utils import get_researcher @@ -137,7 +137,7 @@ class CLIDbLoader(object): else: mode = 'w' - dbclass = GrampsDBDir + dbclass = DbBsddb self.dbstate.change_database(dbclass()) self.dbstate.db.disable_signals() @@ -147,10 +147,10 @@ class CLIDbLoader(object): try: self.dbstate.db.load(filename, self._pulse_progress, mode) self.dbstate.db.set_save_path(filename) - except gen.db.exceptions.GrampsDbUpgradeRequiredError, msg: + except gen.db.exceptions.DbUpgradeRequiredError, msg: self.dbstate.no_database() self._errordialog( _("Cannot open database"), str(msg)) - except gen.db.exceptions.GrampsDbVersionError, msg: + except gen.db.exceptions.DbVersionError, msg: self.dbstate.no_database() self._errordialog( _("Cannot open database"), str(msg)) except OSError, msg: diff --git a/src/gen/db/backup.py b/src/gen/db/backup.py index 4dd65b192..5368497b0 100644 --- a/src/gen/db/backup.py +++ b/src/gen/db/backup.py @@ -58,7 +58,7 @@ import cPickle as pickle # Gramps libs # #------------------------------------------------------------------------ -from gen.db.exceptions import GrampsDbException +from gen.db.exceptions import DbException from gen.db.write import FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, \ EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, META @@ -79,19 +79,19 @@ def backup(database): purpose of this function is to catch any exceptions that occur. @param database: database instance to backup - @type database: GrampsDbDir + @type database: DbDir """ try: __do_export(database) except (OSError, IOError), msg: - raise GrampsDbException(str(msg)) + raise DbException(str(msg)) def __mk_backup_name(database, base): """ Return the backup name of the database table @param database: database instance - @type database: GrampsDbDir + @type database: DbDir @param base: base name of the table @type base: str """ @@ -102,7 +102,7 @@ def __mk_tmp_name(database, base): Return the temporary backup name of the database table @param database: database instance - @type database: GrampsDbDir + @type database: DbDir @param base: base name of the table @type base: str """ @@ -114,7 +114,7 @@ def __do_export(database): a file. @param database: database instance to backup - @type database: GrampsDbDir + @type database: DbDir """ try: for (base, tbl) in __build_tbl_map(database): @@ -147,12 +147,12 @@ def restore(database): purpose of this function is to catch any exceptions that occur. @param database: database instance to restore - @type database: GrampsDbDir + @type database: DbDir """ try: __do_restore(database) except (OSError, IOError), msg: - raise GrampsDbException(str(msg)) + raise DbException(str(msg)) def __do_restore(database): """ @@ -160,7 +160,7 @@ def __do_restore(database): to the appropriate database file. @param database: database instance to backup - @type database: GrampsDbDir + @type database: DbDir """ for (base, tbl) in __build_tbl_map(database): backup_name = __mk_backup_name(database, base) @@ -174,7 +174,7 @@ def __load_tbl_txn(database, backup_table, tbl): Return the temporary backup name of the database table @param database: database instance - @type database: GrampsDbDir + @type database: DbDir @param backup_table: file containing the backup data @type backup_table: file @param tbl: Berkeley db database table @@ -194,7 +194,7 @@ def __build_tbl_map(database): Builds a table map of names to database tables. @param database: database instance to backup - @type database: GrampsDbDir + @type database: DbDir """ return [ ( PERSON_TBL, database.person_map.db), diff --git a/src/gen/db/base.py b/src/gen/db/base.py index 807ef013b..d3f49ccbf 100644 --- a/src/gen/db/base.py +++ b/src/gen/db/base.py @@ -24,32 +24,14 @@ Base class for the GRAMPS databases. All database interfaces should inherit from this class. """ -from __future__ import with_statement -#------------------------------------------------------------------------- -# -# libraries -# -#------------------------------------------------------------------------- -import cPickle -import time -import random -import locale -import os -from sys import maxint -from bsddb import db -from gettext import gettext as _ - #------------------------------------------------------------------------- # # GRAMPS libraries # #------------------------------------------------------------------------- import gen.lib -from gen.lib import (MediaObject, Person, Family, Source, Event, Place, - Repository, Note, GenderStats, Researcher) -from gen.utils.callback import Callback -from gen.db.iterator import CursorIterator -class GrampsDbBase(object): + +class DbReadBase(object): """ GRAMPS database object. This object is a base class for all database interfaces. All methods raise NotImplementedError @@ -58,1428 +40,35 @@ class GrampsDbBase(object): def __init__(self): """ - Create a new GrampsDbBase instance. + Create a new DbReadBase instance. - A new GrampDbBase class should never be directly created. Only classes + A new DbReadBase class should never be directly created. Only classes derived from this class should be created. """ - super(GrampsDbBase, self).__init__() + super(DbReadBase, self).__init__() - def set_prefixes(self, person, media, family, source, place, event, - repository, note): + def all_handles(self, table): """ - Set the prefixes for the gramps ids for all gramps objects + Return all handles from the specified table as a list """ raise NotImplementedError - def rebuild_secondary(self, callback): + def close(self): """ - Rebuild secondary indices + Close the specified database. """ raise NotImplementedError - def version_supported(self): - """Return True when the file has a supported version.""" - raise NotImplementedError - - def need_upgrade(self): - """ - Return True if database needs to be upgraded - """ - raise NotImplementedError - - def gramps_upgrade(self): - """ - Return True if database is upgraded - """ - raise NotImplementedError - - def set_auto_remove(self): - """ - BSDDB change log settings using new method with renamed attributes - """ - raise NotImplementedError - - def write_version(self, name): - """Write version number for a newly created DB.""" - raise NotImplementedError - def create_id(self): """ Create an id """ - raise NotImplementedError - - def get_person_cursor(self): - """ - Return a reference to a cursor over Person objects - """ - raise NotImplementedError - - def get_family_cursor(self): - """ - Return a reference to a cursor over Family objects - """ - raise NotImplementedError - - def get_event_cursor(self): - """ - Return a reference to a cursor over Family objects - """ - raise NotImplementedError - - def get_place_cursor(self): - """ - Return a reference to a cursor over Place objects - """ - raise NotImplementedError - - def get_source_cursor(self): - """ - Return a reference to a cursor over Source objects - """ - raise NotImplementedError - - def get_media_cursor(self): - """ - Return a reference to a cursor over Media objects - """ - raise NotImplementedError - - def get_repository_cursor(self): - """ - Return a reference to a cursor over Repository objects - """ - raise NotImplementedError - - def get_note_cursor(self): - """ - Return a reference to a cursor over Note objects - """ - raise NotImplementedError - - def get_reference_map_cursor(self): - """ - Returns a reference to a cursor over the reference map - """ - raise NotImplementedError - - def get_reference_map_primary_cursor(self): - """ - Returns a reference to a cursor over the reference map primary map - """ - raise NotImplementedError - - def get_reference_map_referenced_cursor(self): - """ - Returns a reference to a cursor over the reference map referenced map - """ - raise NotImplementedError - - def open_undodb(self): - """ - Open the undo database - """ - raise NotImplementedError - - def close_undodb(self): - """ - Close the undo database - """ - raise NotImplementedError - - def load(self, name, callback, mode=None, upgrade=False): - """ - Open the specified database. - """ - raise NotImplementedError - - def close(self): - """ - Close the specified database. - """ - pass - - def is_open(self): - """ - Return True if the database has been opened. - """ - raise NotImplementedError - - def request_rebuild(self): - """ - Notify clients that the data has changed significantly, and that all - internal data dependent on the database should be rebuilt. - Note that all rebuild signals on all objects are emitted at the same - time. It is correct to assume that this is always the case. - TODO: it might be better to replace these rebuild signals by one single - database-rebuild signal. - """ - raise NotImplementedError - - def commit_base(self, obj, data_map, key, transaction, change_time): - """ - Commit the specified object to the database, storing the changes as - part of the transaction. - """ - raise NotImplementedError - - def commit_person(self, person, transaction, change_time=None): - """ - Commit the specified Person to the database, storing the changes as - part of the transaction. - """ - raise NotImplementedError - - def commit_media_object(self, obj, transaction, change_time=None): - """ - Commit the specified MediaObject to the database, storing the changes - as part of the transaction. - """ - raise NotImplementedError - - def commit_source(self, source, transaction, change_time=None): - """ - Commit the specified Source to the database, storing the changes as - part of the transaction. - """ - raise NotImplementedError - - def commit_place(self, place, transaction, change_time=None): - """ - Commit the specified Place to the database, storing the changes as - part of the transaction. - """ - raise NotImplementedError - - def commit_personal_event(self, event, transaction, change_time=None): - """ - Commit the specified personal Event to the database, storing the - changes as part of the transaction. - """ - raise NotImplementedError - - def commit_family_event(self, event, transaction, change_time=None): - """ - Commit the specified family Event to the database, storing the - changes as part of the transaction. - """ - raise NotImplementedError - - def commit_event(self, event, transaction, change_time=None): - """ - Commit the specified Event to the database, storing the changes as - part of the transaction. - """ - raise NotImplementedError - - def commit_family(self, family, transaction, change_time=None): - """ - Commit the specified Family to the database, storing the changes as - part of the transaction. - """ - raise NotImplementedError - - def commit_repository(self, repository, transaction, change_time=None): - """ - Commit the specified Repository to the database, storing the changes - as part of the transaction. - """ - raise NotImplementedError - - def commit_note(self, note, transaction, change_time=None): - """ - Commit the specified Note to the database, storing the changes as part - of the transaction. - """ - raise NotImplementedError - - def find_next_person_gramps_id(self): - """ - Return the next available GRAMPS' ID for a Person object based off the - person ID prefix. - """ - raise NotImplementedError - - def find_next_place_gramps_id(self): - """ - Return the next available GRAMPS' ID for a Place object based off the - place ID prefix. - """ - raise NotImplementedError - - def find_next_event_gramps_id(self): - """ - Return the next available GRAMPS' ID for a Event object based off the - event ID prefix. - """ - raise NotImplementedError - - def find_next_object_gramps_id(self): - """ - Return the next available GRAMPS' ID for a MediaObject object based - off the media object ID prefix. - """ - raise NotImplementedError - - def find_next_source_gramps_id(self): - """ - Return the next available GRAMPS' ID for a Source object based off the - source ID prefix. - """ - raise NotImplementedError - - def find_next_family_gramps_id(self): - """ - Return the next available GRAMPS' ID for a Family object based off the - family ID prefix. - """ - raise NotImplementedError - - def find_next_repository_gramps_id(self): - """ - Return the next available GRAMPS' ID for a Respository object based - off the repository ID prefix. - """ - raise NotImplementedError - - def find_next_note_gramps_id(self): - """ - Return the next available GRAMPS' ID for a Note object based off the - note ID prefix. - """ - raise NotImplementedError - - def get_from_handle(self, handle, class_type, data_map): - """ - Return unserialized data from database given handle and object class - """ - raise NotImplementedError - - def get_person_from_handle(self, handle): - """ - Find a Person in the database from the passed gramps' ID. - - If no such Person exists, None is returned. - """ - raise NotImplementedError - - def get_source_from_handle(self, handle): - """ - Find a Source in the database from the passed gramps' ID. - - If no such Source exists, None is returned. - """ - raise NotImplementedError - - def get_object_from_handle(self, handle): - """ - Find an Object in the database from the passed gramps' ID. - - If no such Object exists, None is returned. - """ - raise NotImplementedError - - def get_place_from_handle(self, handle): - """ - Find a Place in the database from the passed gramps' ID. - - If no such Place exists, None is returned. - """ - raise NotImplementedError - - def get_event_from_handle(self, handle): - """ - Find a Event in the database from the passed gramps' ID. - - If no such Event exists, None is returned. - """ - raise NotImplementedError - - def get_family_from_handle(self, handle): - """ - Find a Family in the database from the passed gramps' ID. - - If no such Family exists, None is returned. - """ - raise NotImplementedError - - def get_repository_from_handle(self, handle): - """ - Find a Repository in the database from the passed gramps' ID. - - If no such Repository exists, None is returned. - """ - raise NotImplementedError - - def get_note_from_handle(self, handle): - """ - Find a Note in the database from the passed gramps' ID. - - If no such Note exists, None is returned. - """ - raise NotImplementedError - - def get_person_from_gramps_id(self, val): - """ - Find a Person in the database from the passed GRAMPS ID. - - If no such Person exists, None is returned. - Needs to be overridden by the derived class. - """ - raise NotImplementedError - - def get_family_from_gramps_id(self, val): - """ - Find a Family in the database from the passed GRAMPS ID. - - If no such Family exists, None is returned. - Need to be overridden by the derived class. - """ - raise NotImplementedError - - def get_event_from_gramps_id(self, val): - """ - Find an Event in the database from the passed GRAMPS ID. - - If no such Event exists, None is returned. - Needs to be overridden by the derived class. - """ - raise NotImplementedError - - def get_place_from_gramps_id(self, val): - """ - Find a Place in the database from the passed gramps' ID. - - If no such Place exists, None is returned. - Needs to be overridden by the derived class. - """ - raise NotImplementedError - - def get_source_from_gramps_id(self, val): - """ - Find a Source in the database from the passed gramps' ID. - - If no such Source exists, None is returned. - Needs to be overridden by the derived class. - """ - raise NotImplementedError - - def get_object_from_gramps_id(self, val): - """ - Find a MediaObject in the database from the passed gramps' ID. - - If no such MediaObject exists, None is returned. - Needs to be overridden by the derived class. - """ - raise NotImplementedError - - def get_repository_from_gramps_id(self, val): - """ - Find a Repository in the database from the passed gramps' ID. - - If no such Repository exists, None is returned. - Needs to be overridden by the derived class. - """ - raise NotImplementedError - - def get_note_from_gramps_id(self, val): - """ - Find a Note in the database from the passed gramps' ID. - - If no such Note exists, None is returned. - Needs to be overridden by the derived classderri. - """ - raise NotImplementedError - - def add_person(self, person, transaction, set_gid=True): - """ - Add a Person to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def add_family(self, family, transaction, set_gid=True): - """ - Add a Family to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def add_source(self, source, transaction, set_gid=True): - """ - Add a Source to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def add_event(self, event, transaction, set_gid=True): - """ - Add an Event to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def add_person_event(self, event, transaction): - """ - Add an Event to the database, assigning internal IDs if they have - not already been defined. - """ - raise NotImplementedError - - def add_family_event(self, event, transaction): - """ - Add an Event to the database, assigning internal IDs if they have - not already been defined. - """ - raise NotImplementedError - - def add_place(self, place, transaction, set_gid=True): - """ - Add a Place to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def add_object(self, obj, transaction, set_gid=True): - """ - Add a MediaObject to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def add_repository(self, obj, transaction, set_gid=True): - """ - Add a Repository to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def add_note(self, obj, transaction, set_gid=True): - """ - Add a Note to the database, assigning internal IDs if they have - not already been defined. - - If not set_gid, then gramps_id is not set. - """ - raise NotImplementedError - - def get_name_group_mapping(self, name): - """ - Return the default grouping name for a surname. - """ - raise NotImplementedError - - def get_name_group_keys(self): - """ - Return the defined names that have been assigned to a default grouping. - """ - raise NotImplementedError - - def has_name_group_key(self, name): - """ - Return if a key exists in the name_group table. - """ - raise NotImplementedError - - def set_name_group_mapping(self, name, group): - """ - Set the default grouping name for a surname. - - Needs to be overridden in the derived class. - """ - raise NotImplementedError - - def get_number_of_people(self): - """ - Return the number of people currently in the database. - """ - raise NotImplementedError - - def get_number_of_families(self): - """ - Return the number of families currently in the database. - """ - raise NotImplementedError - - def get_number_of_events(self): - """ - Return the number of events currently in the database. - """ - raise NotImplementedError - - def get_number_of_places(self): - """ - Return the number of places currently in the database. - """ - raise NotImplementedError - - def get_number_of_sources(self): - """ - Return the number of sources currently in the database. - """ - raise NotImplementedError - - def get_number_of_media_objects(self): - """ - Return the number of media objects currently in the database. - """ - raise NotImplementedError - - def get_number_of_repositories(self): - """ - Return the number of source repositories currently in the database. - """ - raise NotImplementedError - - def get_number_of_notes(self): - """ - Return the number of notes currently in the database. - """ - raise NotImplementedError - - def all_handles(self, table): - """ - Return all handles from the specified table as a list - """ - return table.keys() - - def get_person_handles(self, sort_handles=True): - """ - 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. - """ - raise NotImplementedError - - def get_family_handles(self): - """ - Return a list of database handles, one handle for each Family in - the database. - """ - raise NotImplementedError - - def get_event_handles(self): - """ - Return a list of database handles, one handle for each Event in the - database. - """ - raise NotImplementedError - - def get_place_handles(self, sort_handles=True): - """ - Return a list of database handles, one handle for each Place in - the database. - - If sort_handles is True, the list is sorted by Place title. - """ - raise NotImplementedError - - def get_source_handles(self, sort_handles=True): - """ - Return a list of database handles, one handle for each Source in - the database. - - If sort_handles is True, the list is sorted by Source title. - """ - raise NotImplementedError - - def get_media_object_handles(self, sort_handles=True): - """ - Return a list of database handles, one handle for each MediaObject in - the database. - - If sort_handles is True, the list is sorted by title. - """ - raise NotImplementedError - - def get_repository_handles(self): - """ - Return a list of database handles, one handle for each Repository in - the database. - """ - raise NotImplementedError - - def get_note_handles(self): - """ - Return a list of database handles, one handle for each Note in the - database. - """ - raise NotImplementedError - - def iter_person_handles(self): - """ - Return an iterator over handles for Persons in the database - """ - raise NotImplementedError - - def iter_family_handles(self): - """ - Return an iterator over handles for Families in the database - """ - raise NotImplementedError - - def iter_event_handles(self): - """ - Return an iterator over handles for Events in the database - """ - raise NotImplementedError - - def iter_place_handles(self): - """ - Return an iterator over handles for Places in the database - """ - raise NotImplementedError - - def iter_source_handles(self): - """ - Return an iterator over handles for Sources in the database - """ - raise NotImplementedError - - def iter_media_object_handles(self): - """ - Return an iterator over handles for Media in the database - """ - raise NotImplementedError - - def iter_repository_handles(self): - """ - Return an iterator over handles for Repositories in the database - """ - raise NotImplementedError - - def iter_note_handles(self): - """ - Return an iterator over handles for Notes in the database - """ - raise NotImplementedError - - def iter_people(self): - """ - Return an iterator over objects for Persons in the database - """ - raise NotImplementedError - - def iter_families(self): - """ - Return an iterator over objects for Families in the database - """ - raise NotImplementedError - - def iter_events(self): - """ - Return an iterator over objects for Events in the database - """ - raise NotImplementedError - - def iter_places(self): - """ - Return an iterator over objects for Places in the database - """ - raise NotImplementedError - - def iter_sources(self): - """ - Return an iterator over objects for Sources in the database - """ - raise NotImplementedError - - def iter_media_objects(self): - """ - Return an iterator over objects for MediaObjects in the database - """ - raise NotImplementedError - - def iter_repositories(self): - """ - Return an iterator over objects for Repositories in the database - """ - raise NotImplementedError - - def iter_notes(self): - """ - Return an iterator over objects for Notes in the database - """ - raise NotImplementedError - - def get_gramps_ids(self, obj_key): - """ - Returns all the keys from a table given a table name - """ - raise NotImplementedError - - def has_gramps_id(self, obj_key, gramps_id): - """ - Returns True if the key exists in table given a table name - - Not used in current codebase - """ - raise NotImplementedError - - def find_initial_person(self): - """ - Returns first person in the database - """ - raise NotImplementedError - - def set_person_id_prefix(self, val): - """ - Set the naming template for GRAMPS Person ID values. - - The string is expected to be in the form of a simple text string, or - in a format that contains a C/Python style format string using %d, - such as I%d or I%04d. - """ - raise NotImplementedError - - def set_source_id_prefix(self, val): - """ - Set the naming template for GRAMPS Source ID values. - - The string is expected to be in the form of a simple text string, or - in a format that contains a C/Python style format string using %d, - such as S%d or S%04d. - """ - raise NotImplementedError - - def set_object_id_prefix(self, val): - """ - Set the naming template for GRAMPS MediaObject ID values. - - The string is expected to be in the form of a simple text string, or - in a format that contains a C/Python style format string using %d, - such as O%d or O%04d. - """ - raise NotImplementedError - - def set_place_id_prefix(self, val): - """ - Set the naming template for GRAMPS Place ID values. - - The string is expected to be in the form of a simple text string, or - in a format that contains a C/Python style format string using %d, - such as P%d or P%04d. - """ - raise NotImplementedError - - def set_family_id_prefix(self, val): - """ - Set the naming template for GRAMPS Family ID values. The string is - expected to be in the form of a simple text string, or in a format - that contains a C/Python style format string using %d, such as F%d - or F%04d. - """ - raise NotImplementedError - - def set_event_id_prefix(self, val): - """ - Set the naming template for GRAMPS Event ID values. - - The string is expected to be in the form of a simple text string, or - in a format that contains a C/Python style format string using %d, - such as E%d or E%04d. - """ - raise NotImplementedError - - def set_repository_id_prefix(self, val): - """ - Set the naming template for GRAMPS Repository ID values. - - The string is expected to be in the form of a simple text string, or - in a format that contains a C/Python style format string using %d, - such as R%d or R%04d. - """ - raise NotImplementedError - - def set_note_id_prefix(self, val): - """ - Set the naming template for GRAMPS Note ID values. - - The string is expected to be in the form of a simple text string, or - in a format that contains a C/Python style format string using %d, - such as N%d or N%04d. - """ - raise NotImplementedError - - def transaction_begin(self, msg="", batch=False, no_magic=False): - """ - Create a new Transaction tied to the current UNDO database. - - The transaction has no effect until it is committed using the - transaction_commit function of the this database object. - """ - raise NotImplementedError - - def transaction_commit(self, transaction, msg): - """ - Commit the transaction to the associated UNDO database. - """ - raise NotImplementedError - - def set_undo_callback(self, callback): - """ - Define the callback function that is called whenever an undo operation - is executed. - - The callback function receives a single argument that is a text string - that defines the operation. - """ - raise NotImplementedError - - def set_redo_callback(self, callback): - """ - Define the callback function that is called whenever an redo operation - is executed. - - The callback function receives a single argument that is a text string - that defines the operation. - """ - raise NotImplementedError - - def get_surname_list(self): - """ - Return the list of locale-sorted surnames contained in the database. - """ - raise NotImplementedError - - def build_surname_list(self): - """ - Build the list of locale-sorted surnames contained in the database. - """ - raise NotImplementedError - - def sort_surname_list(self): - """ - Sort the list of surnames contained in the database by locale ordering. - """ - raise NotImplementedError - - def add_to_surname_list(self, person, batch_transaction): - """ - Add surname from given person to list of surnames - """ - raise NotImplementedError - if batch_transaction: - return - name = unicode(person.get_primary_name().get_surname()) - if name not in self.surname_list: - self.surname_list.append(name) - self.sort_surname_list() - - def remove_from_surname_list(self, person): - """ - Check whether there are persons with the same surname left in - the database. - - If not then we need to remove the name from the list. - The function must be overridden in the derived class. - """ - raise NotImplementedError - - def get_bookmarks(self): - """Return the list of Person handles in the bookmarks.""" - raise NotImplementedError - - def get_family_bookmarks(self): - """Return the list of Person handles in the bookmarks.""" - raise NotImplementedError - - def get_event_bookmarks(self): - """Return the list of Person handles in the bookmarks.""" - raise NotImplementedError - - def get_place_bookmarks(self): - """Return the list of Person handles in the bookmarks.""" - raise NotImplementedError - - def get_source_bookmarks(self): - """Return the list of Person handles in the bookmarks.""" - raise NotImplementedError - - def get_media_bookmarks(self): - """Return the list of Person handles in the bookmarks.""" - raise NotImplementedError - - def get_repo_bookmarks(self): - """Return the list of Person handles in the bookmarks.""" - raise NotImplementedError - - def get_note_bookmarks(self): - """Return the list of Note handles in the bookmarks.""" - raise NotImplementedError - - def set_researcher(self, owner): - """Set the information about the owner of the database.""" - raise NotImplementedError - - def get_researcher(self): - """ - Return the Researcher instance, providing information about the owner - of the database. - """ - raise NotImplementedError - - def set_default_person_handle(self, handle): - """Set the default Person to the passed instance.""" - raise NotImplementedError - - def get_default_person(self): - """Return the default Person of the database.""" - raise NotImplementedError - - def get_default_handle(self): - """Return the default Person of the database.""" - raise NotImplementedError - - def get_save_path(self): - """Return the save path of the file, or "" if one does not exist.""" - raise NotImplementedError - - def set_save_path(self, path): - """Set the save path for the database.""" - raise NotImplementedError - - def get_person_event_types(self): - """ - Return a list of all Event types associated with Person instances in - the database. - """ - raise NotImplementedError - - def get_person_attribute_types(self): - """ - Return a list of all Attribute types associated with Person instances - in the database. - """ - raise NotImplementedError - - def get_family_attribute_types(self): - """ - Return a list of all Attribute types associated with Family instances - in the database. - """ - raise NotImplementedError - - def get_family_event_types(self): - """ - Return a list of all Event types associated with Family instances in - the database. - """ - raise NotImplementedError - - def get_marker_types(self): - """ - Return a list of all marker types available in the database. - """ - raise NotImplementedError - - def get_media_attribute_types(self): - """ - Return a list of all Attribute types associated with Media and MediaRef - instances in the database. - """ - raise NotImplementedError - - def get_family_relation_types(self): - """ - Return a list of all relationship types associated with Family - instances in the database. - """ - raise NotImplementedError - - def get_child_reference_types(self): - """ - Return a list of all child reference types associated with Family - instances in the database. - """ - raise NotImplementedError - - def get_event_roles(self): - """ - Return a list of all custom event role names associated with Event - instances in the database. - """ - raise NotImplementedError - - def get_name_types(self): - """ - Return a list of all custom names types associated with Person - instances in the database. - """ - raise NotImplementedError - - def get_repository_types(self): - """ - Return a list of all custom repository types associated with Repository - instances in the database. - """ - raise NotImplementedError - - def get_note_types(self): - """ - Return a list of all custom note types associated with Note instances - in the database. - """ - raise NotImplementedError - - def get_source_media_types(self): - """ - Return a list of all custom source media types associated with Source - instances in the database. - """ - raise NotImplementedError - - def get_url_types(self): - """ - Return a list of all custom names types associated with Url instances - in the database. - """ - raise NotImplementedError - - def remove_person(self, handle, transaction): - """ - Remove the Person specified by the database handle from the database, - preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def get_del_func(self, key): - """ - Returns the key of an object to delete - """ - raise NotImplementedError - - def remove_source(self, handle, transaction): - """ - Remove the Source specified by the database handle from the - database, preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def remove_event(self, handle, transaction): - """ - Remove the Event specified by the database handle from the - database, preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def remove_object(self, handle, transaction): - """ - Remove the MediaObjectPerson specified by the database handle from the - database, preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def remove_place(self, handle, transaction): - """ - Remove the Place specified by the database handle from the - database, preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def remove_family(self, handle, transaction): - """ - Remove the Family specified by the database handle from the - database, preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def remove_repository(self, handle, transaction): - """ - Remove the Repository specified by the database handle from the - database, preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def remove_note(self, handle, transaction): - """ - Remove the Note specified by the database handle from the - database, preserving the change in the passed transaction. - - This method must be overridden in the derived class. - """ - raise NotImplementedError - - def get_raw_person_data(self, handle): - """ - Return raw (serialized and pickled) Person object from handle - """ - raise NotImplementedError - - def get_raw_family_data(self, handle): - """ - Return raw (serialized and pickled) Family object from handle - """ - raise NotImplementedError - - def get_raw_object_data(self, handle): - """ - Return raw (serialized and pickled) Family object from handle - """ - raise NotImplementedError - - def get_raw_place_data(self, handle): - """ - Return raw (serialized and pickled) Place object from handle - """ - raise NotImplementedError - - def get_raw_event_data(self, handle): - """ - Return raw (serialized and pickled) Event object from handle - """ - raise NotImplementedError - - def get_raw_source_data(self, handle): - """ - Return raw (serialized and pickled) Source object from handle - """ - raise NotImplementedError - - def get_raw_repository_data(self, handle): - """ - Return raw (serialized and pickled) Repository object from handle - """ - raise NotImplementedError - - def get_raw_note_data(self, handle): - """ - Return raw (serialized and pickled) Note object from handle - """ - raise NotImplementedError - - def has_person_handle(self, handle): - """ - Return True if the handle exists in the current Person database. - """ - raise NotImplementedError - - def has_event_handle(self, handle): - """ - Return True if the handle exists in the current Event database. - """ - raise NotImplementedError - - def has_source_handle(self, handle): - """ - Return True if the handle exists in the current Source database. - """ - raise NotImplementedError - - def has_place_handle(self, handle): - """ - Return True if the handle exists in the current Place database. - """ - raise NotImplementedError - - def has_family_handle(self, handle): - """ - Return True if the handle exists in the current Family database. - """ - raise NotImplementedError - - def has_object_handle(self, handle): - """ - Return True if the handle exists in the current MediaObjectdatabase. - """ - raise NotImplementedError - - def has_repository_handle(self, handle): - """ - Return True if the handle exists in the current Repository database. - """ - raise NotImplementedError - - def has_note_handle(self, handle): - """ - Return True if the handle exists in the current Note database. - """ - raise NotImplementedError - - def set_mediapath(self, path): - """Set the default media path for database, path should be utf-8.""" - raise NotImplementedError - - def get_mediapath(self): - """Return the default media path of the database.""" - raise NotImplementedError - - def set_column_order(self, col_list, name): - """ - Store the display information in the database's metadata. - """ - raise NotImplementedError - - def set_person_column_order(self, col_list): - """ - Store the Person display common information in the database's metadata. - """ - raise NotImplementedError - - def set_family_list_column_order(self, col_list): - """ - Store the Person display common information in the database's metadata. - """ - raise NotImplementedError - - def set_child_column_order(self, col_list): - """ - Store the Person display common information in the database's metadata. - """ - raise NotImplementedError - - def set_place_column_order(self, col_list): - """ - Store the Place display common information in the database's metadata. - """ - raise NotImplementedError - - def set_source_column_order(self, col_list): - """ - Store the Source display common information in the database's metadata. - """ - raise NotImplementedError - - def set_media_column_order(self, col_list): - """ - Store the Media display common information in the database's metadata. - """ - raise NotImplementedError - - def set_event_column_order(self, col_list): - """ - Store the Event display common information in the database's metadata. - """ - raise NotImplementedError - - def set_repository_column_order(self, col_list): - """ - Store the Repository display common information in the database's - metadata. - """ - raise NotImplementedError - - def set_note_column_order(self, col_list): - """ - Store the Note display common information in the database's metadata. - """ - raise NotImplementedError - - def get_person_column_order(self): - """ - Return the Person display common information stored in the database's - metadata. - """ - raise NotImplementedError - - def get_family_list_column_order(self): - """ - Return the Person display common information stored in the database's - metadata. - """ - raise NotImplementedError - - def get_child_column_order(self): - """ - Return the Person display common information stored in the database's - metadata. - """ - raise NotImplementedError - - def get_place_column_order(self): - """ - Return the Place display common information stored in thedatabase's - metadata. - """ - raise NotImplementedError - - def get_source_column_order(self): - """ - Return the Source display common information stored in the database's - metadata. - """ - raise NotImplementedError - - def get_media_column_order(self): - """ - Return the MediaObject display common information stored in the - database's metadata. - """ - raise NotImplementedError - - def get_event_column_order(self): - """ - Return the Event display common information stored in the database's - metadata. - """ - raise NotImplementedError - - def get_repository_column_order(self): - """ - Return the Repository display common information stored in the - database's metadata. - """ - raise NotImplementedError - - def get_note_column_order(self): - """ - Return the Note display common information stored in the database's - metadata. - """ - raise NotImplementedError - - def delete_primary_from_reference_map(self, handle, transaction): - """ - Called each time an object is removed from the database. - - This can be used by subclasses to update any additional index tables - that might need to be changed. - """ - raise NotImplementedError - - def update_reference_map(self, obj, transaction): - """ - Called each time an object is writen to the database. - - This can be used by subclasses to update any additional index tables - that might need to be changed. - """ raise NotImplementedError - def reindex_reference_map(self, callback): + def db_has_bm_changes(self): """ - Reindex all primary records in the database. + Return whethere there were bookmark changes during the session. """ raise NotImplementedError @@ -1505,7 +94,868 @@ class GrampsDbBase(object): result_list = list(find_backlink_handles(handle)) """ + raise NotImplementedError + def find_initial_person(self): + """ + Returns first person in the database + """ + raise NotImplementedError + + def find_next_event_gramps_id(self): + """ + Return the next available GRAMPS' ID for a Event object based off the + event ID prefix. + """ + raise NotImplementedError + + def find_next_family_gramps_id(self): + """ + Return the next available GRAMPS' ID for a Family object based off the + family ID prefix. + """ + raise NotImplementedError + + def find_next_note_gramps_id(self): + """ + Return the next available GRAMPS' ID for a Note object based off the + note ID prefix. + """ + raise NotImplementedError + + def find_next_object_gramps_id(self): + """ + Return the next available GRAMPS' ID for a MediaObject object based + off the media object ID prefix. + """ + raise NotImplementedError + + def find_next_person_gramps_id(self): + """ + Return the next available GRAMPS' ID for a Person object based off the + person ID prefix. + """ + raise NotImplementedError + + def find_next_place_gramps_id(self): + """ + Return the next available GRAMPS' ID for a Place object based off the + place ID prefix. + """ + raise NotImplementedError + + def find_next_repository_gramps_id(self): + """ + Return the next available GRAMPS' ID for a Respository object based + off the repository ID prefix. + """ + raise NotImplementedError + + def find_next_source_gramps_id(self): + """ + Return the next available GRAMPS' ID for a Source object based off the + source ID prefix. + """ + raise NotImplementedError + + def get_bookmarks(self): + """ + Return the list of Person handles in the bookmarks. + """ + raise NotImplementedError + + def get_child_reference_types(self): + """ + Return a list of all child reference types associated with Family + instances in the database. + """ + raise NotImplementedError + + def get_default_handle(self): + """ + Return the default Person of the database. + """ + raise NotImplementedError + + def get_default_person(self): + """ + Return the default Person of the database. + """ + raise NotImplementedError + + def get_event_bookmarks(self): + """ + Return the list of Person handles in the bookmarks. + """ + raise NotImplementedError + + def get_event_column_order(self): + """ + Return the Event display common information stored in the database's + metadata. + """ + raise NotImplementedError + + def get_event_cursor(self): + """ + Return a reference to a cursor over Family objects + """ + raise NotImplementedError + + def get_event_from_gramps_id(self, val): + """ + Find an Event in the database from the passed GRAMPS ID. + + If no such Event exists, None is returned. + Needs to be overridden by the derived class. + """ + raise NotImplementedError + + def get_event_from_handle(self, handle): + """ + Find a Event in the database from the passed gramps' ID. + + If no such Event exists, None is returned. + """ + raise NotImplementedError + + def get_event_handles(self): + """ + Return a list of database handles, one handle for each Event in the + database. + """ + raise NotImplementedError + + def get_event_roles(self): + """ + Return a list of all custom event role names associated with Event + instances in the database. + """ + raise NotImplementedError + + def get_family_attribute_types(self): + """ + Return a list of all Attribute types associated with Family instances + in the database. + """ + raise NotImplementedError + + def get_family_bookmarks(self): + """ + Return the list of Person handles in the bookmarks. + """ + raise NotImplementedError + + def get_family_cursor(self): + """ + Return a reference to a cursor over Family objects + """ + raise NotImplementedError + + def get_family_event_types(self): + """ + Return a list of all Event types associated with Family instances in + the database. + """ + raise NotImplementedError + + def get_family_from_gramps_id(self, val): + """ + Find a Family in the database from the passed GRAMPS ID. + + If no such Family exists, None is returned. + Need to be overridden by the derived class. + """ + raise NotImplementedError + + def get_family_from_handle(self, handle): + """ + Find a Family in the database from the passed gramps' ID. + + If no such Family exists, None is returned. + """ + raise NotImplementedError + + def get_family_handles(self): + """ + Return a list of database handles, one handle for each Family in + the database. + """ + raise NotImplementedError + + def get_family_list_column_order(self): + """ + Return the Person display common information stored in the database's + metadata. + """ + raise NotImplementedError + + def get_family_relation_types(self): + """ + Return a list of all relationship types associated with Family + instances in the database. + """ + raise NotImplementedError + + def get_from_handle(self, handle, class_type, data_map): + """ + Return unserialized data from database given handle and object class + """ + raise NotImplementedError + + def get_gramps_ids(self, obj_key): + """ + Returns all the keys from a table given a table name + """ + raise NotImplementedError + + def get_marker_types(self): + """ + Return a list of all marker types available in the database. + """ + raise NotImplementedError + + def get_media_attribute_types(self): + """ + Return a list of all Attribute types associated with Media and MediaRef + instances in the database. + """ + raise NotImplementedError + + def get_media_bookmarks(self): + """ + Return the list of Person handles in the bookmarks. + """ + raise NotImplementedError + + def get_media_column_order(self): + """ + Return the MediaObject display common information stored in the + database's metadata. + """ + raise NotImplementedError + + def get_media_cursor(self): + """ + Return a reference to a cursor over Media objects + """ + raise NotImplementedError + + def get_media_object_handles(self, sort_handles=True): + """ + Return a list of database handles, one handle for each MediaObject in + the database. + + If sort_handles is True, the list is sorted by title. + """ + raise NotImplementedError + + def get_mediapath(self): + """ + Return the default media path of the database. + """ + raise NotImplementedError + + def get_name_group_keys(self): + """ + Return the defined names that have been assigned to a default grouping. + """ + raise NotImplementedError + + def get_name_group_mapping(self, name): + """ + Return the default grouping name for a surname. + """ + raise NotImplementedError + + def get_name_types(self): + """ + Return a list of all custom names types associated with Person + instances in the database. + """ + raise NotImplementedError + + def get_note_bookmarks(self): + """ + Return the list of Note handles in the bookmarks. + """ + raise NotImplementedError + + def get_note_column_order(self): + """ + Return the Note display common information stored in the database's + metadata. + """ + raise NotImplementedError + + def get_note_cursor(self): + """ + Return a reference to a cursor over Note objects + """ + raise NotImplementedError + + def get_note_from_gramps_id(self, val): + """ + Find a Note in the database from the passed gramps' ID. + + If no such Note exists, None is returned. + Needs to be overridden by the derived classderri. + """ + raise NotImplementedError + + def get_note_from_handle(self, handle): + """ + Find a Note in the database from the passed gramps' ID. + + If no such Note exists, None is returned. + """ + raise NotImplementedError + + def get_note_handles(self): + """ + Return a list of database handles, one handle for each Note in the + database. + """ + raise NotImplementedError + + def get_note_types(self): + """ + Return a list of all custom note types associated with Note instances + in the database. + """ + raise NotImplementedError + + def get_number_of_events(self): + """ + Return the number of events currently in the database. + """ + raise NotImplementedError + + def get_number_of_families(self): + """ + Return the number of families currently in the database. + """ + raise NotImplementedError + + def get_number_of_media_objects(self): + """ + Return the number of media objects currently in the database. + """ + raise NotImplementedError + + def get_number_of_notes(self): + """ + Return the number of notes currently in the database. + """ + raise NotImplementedError + + def get_number_of_people(self): + """ + Return the number of people currently in the database. + """ + raise NotImplementedError + + def get_number_of_places(self): + """ + Return the number of places currently in the database. + """ + raise NotImplementedError + + def get_number_of_repositories(self): + """ + Return the number of source repositories currently in the database. + """ + raise NotImplementedError + + def get_number_of_sources(self): + """ + Return the number of sources currently in the database. + """ + raise NotImplementedError + + def get_object_from_gramps_id(self, val): + """ + Find a MediaObject in the database from the passed gramps' ID. + + If no such MediaObject exists, None is returned. + Needs to be overridden by the derived class. + """ + raise NotImplementedError + + def get_object_from_handle(self, handle): + """ + Find an Object in the database from the passed gramps' ID. + + If no such Object exists, None is returned. + """ + raise NotImplementedError + + def get_person_attribute_types(self): + """ + Return a list of all Attribute types associated with Person instances + in the database. + """ + raise NotImplementedError + + def get_person_column_order(self): + """ + Return the Person display common information stored in the database's + metadata. + """ + raise NotImplementedError + + def get_person_cursor(self): + """ + Return a reference to a cursor over Person objects + """ + raise NotImplementedError + + def get_person_event_types(self): + """ + Return a list of all Event types associated with Person instances in + the database. + """ + raise NotImplementedError + + def get_person_from_gramps_id(self, val): + """ + Find a Person in the database from the passed GRAMPS ID. + + If no such Person exists, None is returned. + Needs to be overridden by the derived class. + """ + raise NotImplementedError + + def get_person_from_handle(self, handle): + """ + Find a Person in the database from the passed gramps' ID. + + If no such Person exists, None is returned. + """ + raise NotImplementedError + + def get_person_handles(self, sort_handles=True): + """ + 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. + """ + raise NotImplementedError + + def get_place_bookmarks(self): + """ + Return the list of Person handles in the bookmarks. + """ + raise NotImplementedError + + def get_place_column_order(self): + """ + Return the Place display common information stored in thedatabase's + metadata. + """ + raise NotImplementedError + + def get_place_cursor(self): + """ + Return a reference to a cursor over Place objects + """ + raise NotImplementedError + + def get_place_from_gramps_id(self, val): + """ + Find a Place in the database from the passed gramps' ID. + + If no such Place exists, None is returned. + Needs to be overridden by the derived class. + """ + raise NotImplementedError + + def get_place_from_handle(self, handle): + """ + Find a Place in the database from the passed gramps' ID. + + If no such Place exists, None is returned. + """ + raise NotImplementedError + + def get_place_handles(self, sort_handles=True): + """ + Return a list of database handles, one handle for each Place in + the database. + + If sort_handles is True, the list is sorted by Place title. + """ + raise NotImplementedError + + def get_raw_event_data(self, handle): + """ + Return raw (serialized and pickled) Event object from handle + """ + raise NotImplementedError + + def get_raw_family_data(self, handle): + """ + Return raw (serialized and pickled) Family object from handle + """ + raise NotImplementedError + + def get_raw_note_data(self, handle): + """ + Return raw (serialized and pickled) Note object from handle + """ + raise NotImplementedError + + def get_raw_object_data(self, handle): + """ + Return raw (serialized and pickled) Family object from handle + """ + raise NotImplementedError + + def get_raw_person_data(self, handle): + """ + Return raw (serialized and pickled) Person object from handle + """ + raise NotImplementedError + + def get_raw_place_data(self, handle): + """ + Return raw (serialized and pickled) Place object from handle + """ + raise NotImplementedError + + def get_raw_repository_data(self, handle): + """ + Return raw (serialized and pickled) Repository object from handle + """ + raise NotImplementedError + + def get_raw_source_data(self, handle): + """ + Return raw (serialized and pickled) Source object from handle + """ + raise NotImplementedError + + def get_reference_map_cursor(self): + """ + Returns a reference to a cursor over the reference map + """ + raise NotImplementedError + + def get_reference_map_primary_cursor(self): + """ + Returns a reference to a cursor over the reference map primary map + """ + raise NotImplementedError + + def get_reference_map_referenced_cursor(self): + """ + Returns a reference to a cursor over the reference map referenced map + """ + raise NotImplementedError + + def get_repo_bookmarks(self): + """ + Return the list of Person handles in the bookmarks. + """ + raise NotImplementedError + + def get_repository_column_order(self): + """ + Return the Repository display common information stored in the + database's metadata. + """ + raise NotImplementedError + + def get_repository_cursor(self): + """ + Return a reference to a cursor over Repository objects + """ + raise NotImplementedError + + def get_repository_from_gramps_id(self, val): + """ + Find a Repository in the database from the passed gramps' ID. + + If no such Repository exists, None is returned. + Needs to be overridden by the derived class. + """ + raise NotImplementedError + + def get_repository_from_handle(self, handle): + """ + Find a Repository in the database from the passed gramps' ID. + + If no such Repository exists, None is returned. + """ + raise NotImplementedError + + def get_repository_handles(self): + """ + Return a list of database handles, one handle for each Repository in + the database. + """ + raise NotImplementedError + + def get_repository_types(self): + """ + Return a list of all custom repository types associated with Repository + instances in the database. + """ + raise NotImplementedError + + def get_researcher(self): + """ + Return the Researcher instance, providing information about the owner + of the database. + """ + raise NotImplementedError + + def get_save_path(self): + """ + Return the save path of the file, or "" if one does not exist. + """ + raise NotImplementedError + + def get_source_bookmarks(self): + """ + Return the list of Person handles in the bookmarks. + """ + raise NotImplementedError + + def get_source_column_order(self): + """ + Return the Source display common information stored in the database's + metadata. + """ + raise NotImplementedError + + def get_source_cursor(self): + """ + Return a reference to a cursor over Source objects + """ + raise NotImplementedError + + def get_source_from_gramps_id(self, val): + """ + Find a Source in the database from the passed gramps' ID. + + If no such Source exists, None is returned. + Needs to be overridden by the derived class. + """ + raise NotImplementedError + + def get_source_from_handle(self, handle): + """ + Find a Source in the database from the passed gramps' ID. + + If no such Source exists, None is returned. + """ + raise NotImplementedError + + def get_source_handles(self, sort_handles=True): + """ + Return a list of database handles, one handle for each Source in + the database. + + If sort_handles is True, the list is sorted by Source title. + """ + raise NotImplementedError + + def get_source_media_types(self): + """ + Return a list of all custom source media types associated with Source + instances in the database. + """ + raise NotImplementedError + + def get_surname_list(self): + """ + Return the list of locale-sorted surnames contained in the database. + """ + raise NotImplementedError + + def get_url_types(self): + """ + Return a list of all custom names types associated with Url instances + in the database. + """ + raise NotImplementedError + + def gramps_upgrade(self): + """ + Return True if database is upgraded + """ + raise NotImplementedError + + def has_event_handle(self, handle): + """ + Return True if the handle exists in the current Event database. + """ + raise NotImplementedError + + def has_family_handle(self, handle): + """ + Return True if the handle exists in the current Family database. + """ + raise NotImplementedError + + def has_gramps_id(self, obj_key, gramps_id): + """ + Returns True if the key exists in table given a table name + + Not used in current codebase + """ + raise NotImplementedError + + def has_name_group_key(self, name): + """ + Return if a key exists in the name_group table. + """ + raise NotImplementedError + + def has_note_handle(self, handle): + """ + Return True if the handle exists in the current Note database. + """ + raise NotImplementedError + + def has_object_handle(self, handle): + """ + Return True if the handle exists in the current MediaObjectdatabase. + """ + raise NotImplementedError + + def has_person_handle(self, handle): + """ + Return True if the handle exists in the current Person database. + """ + raise NotImplementedError + + def has_place_handle(self, handle): + """ + Return True if the handle exists in the current Place database. + """ + raise NotImplementedError + + def has_repository_handle(self, handle): + """ + Return True if the handle exists in the current Repository database. + """ + raise NotImplementedError + + def has_source_handle(self, handle): + """ + Return True if the handle exists in the current Source database. + """ + raise NotImplementedError + + def is_open(self): + """ + Return True if the database has been opened. + """ + raise NotImplementedError + + def iter_event_handles(self): + """ + Return an iterator over handles for Events in the database + """ + raise NotImplementedError + + def iter_events(self): + """ + Return an iterator over objects for Events in the database + """ + raise NotImplementedError + + def iter_families(self): + """ + Return an iterator over objects for Families in the database + """ + raise NotImplementedError + + def iter_family_handles(self): + """ + Return an iterator over handles for Families in the database + """ + raise NotImplementedError + + def iter_media_object_handles(self): + """ + Return an iterator over handles for Media in the database + """ + raise NotImplementedError + + def iter_media_objects(self): + """ + Return an iterator over objects for MediaObjects in the database + """ + raise NotImplementedError + + def iter_note_handles(self): + """ + Return an iterator over handles for Notes in the database + """ + raise NotImplementedError + + def iter_notes(self): + """ + Return an iterator over objects for Notes in the database + """ + raise NotImplementedError + + def iter_people(self): + """ + Return an iterator over objects for Persons in the database + """ + raise NotImplementedError + + def iter_person_handles(self): + """ + Return an iterator over handles for Persons in the database + """ + raise NotImplementedError + + def iter_place_handles(self): + """ + Return an iterator over handles for Places in the database + """ + raise NotImplementedError + + def iter_places(self): + """ + Return an iterator over objects for Places in the database + """ + raise NotImplementedError + + def iter_repositories(self): + """ + Return an iterator over objects for Repositories in the database + """ + raise NotImplementedError + + def iter_repository_handles(self): + """ + Return an iterator over handles for Repositories in the database + """ + raise NotImplementedError + + def iter_source_handles(self): + """ + Return an iterator over handles for Sources in the database + """ + raise NotImplementedError + + def iter_sources(self): + """ + Return an iterator over objects for Sources in the database + """ + raise NotImplementedError + + def load(self, name, callback, mode=None, upgrade=False): + """ + Open the specified database. + """ raise NotImplementedError def report_bm_change(self): @@ -1514,9 +964,568 @@ class GrampsDbBase(object): """ raise NotImplementedError - def db_has_bm_changes(self): + def request_rebuild(self): """ - Return whethere there were bookmark changes during the session. + Notify clients that the data has changed significantly, and that all + internal data dependent on the database should be rebuilt. + Note that all rebuild signals on all objects are emitted at the same + time. It is correct to assume that this is always the case. + TODO: it might be better to replace these rebuild signals by one single + database-rebuild signal. + """ + raise NotImplementedError + + def version_supported(self): + """ + Return True when the file has a supported version. + """ + raise NotImplementedError + + def set_event_id_prefix(self, val): + """ + Set the naming template for GRAMPS Event ID values. + + The string is expected to be in the form of a simple text string, or + in a format that contains a C/Python style format string using %d, + such as E%d or E%04d. + """ + raise NotImplementedError + + def set_family_id_prefix(self, val): + """ + Set the naming template for GRAMPS Family ID values. The string is + expected to be in the form of a simple text string, or in a format + that contains a C/Python style format string using %d, such as F%d + or F%04d. + """ + raise NotImplementedError + + def set_note_id_prefix(self, val): + """ + Set the naming template for GRAMPS Note ID values. + + The string is expected to be in the form of a simple text string, or + in a format that contains a C/Python style format string using %d, + such as N%d or N%04d. + """ + raise NotImplementedError + + def set_object_id_prefix(self, val): + """ + Set the naming template for GRAMPS MediaObject ID values. + + The string is expected to be in the form of a simple text string, or + in a format that contains a C/Python style format string using %d, + such as O%d or O%04d. + """ + raise NotImplementedError + + def set_person_id_prefix(self, val): + """ + Set the naming template for GRAMPS Person ID values. + + The string is expected to be in the form of a simple text string, or + in a format that contains a C/Python style format string using %d, + such as I%d or I%04d. + """ + raise NotImplementedError + + def set_place_id_prefix(self, val): + """ + Set the naming template for GRAMPS Place ID values. + + The string is expected to be in the form of a simple text string, or + in a format that contains a C/Python style format string using %d, + such as P%d or P%04d. + """ + raise NotImplementedError + + def set_prefixes(self, person, media, family, source, place, event, repository, note): + """ + Set the prefixes for the gramps ids for all gramps objects + """ + raise NotImplementedError + + def set_repository_id_prefix(self, val): + """ + Set the naming template for GRAMPS Repository ID values. + + The string is expected to be in the form of a simple text string, or + in a format that contains a C/Python style format string using %d, + such as R%d or R%04d. + """ + raise NotImplementedError + + def set_source_id_prefix(self, val): + """ + Set the naming template for GRAMPS Source ID values. + + The string is expected to be in the form of a simple text string, or + in a format that contains a C/Python style format string using %d, + such as S%d or S%04d. + """ + raise NotImplementedError + + def get_child_column_order(self): + """ + Return the Person display common information stored in the database's + metadata. + """ + raise NotImplementedError + + def set_child_column_order(self, col_list): + """ + Store the Person display common information in the database's metadata. + """ + raise NotImplementedError + + def set_column_order(self, col_list, name): + """ + Store the display information in the database's metadata. + """ + raise NotImplementedError + + def set_event_column_order(self, col_list): + """ + Store the Event display common information in the database's metadata. + """ + raise NotImplementedError + + def set_family_list_column_order(self, col_list): + """ + Store the Person display common information in the database's metadata. + """ + raise NotImplementedError + + def set_media_column_order(self, col_list): + """ + Store the Media display common information in the database's metadata. + """ + raise NotImplementedError + + def set_note_column_order(self, col_list): + """ + Store the Note display common information in the database's metadata. + """ + raise NotImplementedError + + def set_person_column_order(self, col_list): + """ + Store the Person display common information in the database's metadata. + """ + raise NotImplementedError + + def set_place_column_order(self, col_list): + """ + Store the Place display common information in the database's metadata. + """ + raise NotImplementedError + + def set_repository_column_order(self, col_list): + """ + Store the Repository display common information in the database's + metadata. + """ + raise NotImplementedError + + def set_source_column_order(self, col_list): + """ + Store the Source display common information in the database's metadata. + """ + raise NotImplementedError + + def set_mediapath(self, path): + """ + Set the default media path for database, path should be utf-8. + """ + raise NotImplementedError + + def set_redo_callback(self, callback): + """ + Define the callback function that is called whenever an redo operation + is executed. + + The callback function receives a single argument that is a text string + that defines the operation. + """ + raise NotImplementedError + + def set_researcher(self, owner): + """ + Set the information about the owner of the database. + """ + raise NotImplementedError + + def set_save_path(self, path): + """ + Set the save path for the database. + """ + raise NotImplementedError + + def set_undo_callback(self, callback): + """ + Define the callback function that is called whenever an undo operation + is executed. + + The callback function receives a single argument that is a text string + that defines the operation. + """ + raise NotImplementedError + +class DbWriteBase(DbReadBase): + """ + GRAMPS database object. This object is a base class for all + database interfaces. All methods raise NotImplementedError + and must be implemented in the derived class as required. + """ + + def __init__(self): + """ + Create a new DbWriteBase instance. + + A new DbWriteBase class should never be directly created. Only classes + derived from this class should be created. + """ + + super(DbWriteBase, self).__init__() + + def add_event(self, event, transaction, set_gid=True): + """ + Add an Event to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_family(self, family, transaction, set_gid=True): + """ + Add a Family to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_family_event(self, event, transaction): + """ + Add an Event to the database, assigning internal IDs if they have + not already been defined. + """ + raise NotImplementedError + + def add_note(self, obj, transaction, set_gid=True): + """ + Add a Note to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_object(self, obj, transaction, set_gid=True): + """ + Add a MediaObject to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_person(self, person, transaction, set_gid=True): + """ + Add a Person to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_person_event(self, event, transaction): + """ + Add an Event to the database, assigning internal IDs if they have + not already been defined. + """ + raise NotImplementedError + + def add_place(self, place, transaction, set_gid=True): + """ + Add a Place to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_repository(self, obj, transaction, set_gid=True): + """ + Add a Repository to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_source(self, source, transaction, set_gid=True): + """ + Add a Source to the database, assigning internal IDs if they have + not already been defined. + + If not set_gid, then gramps_id is not set. + """ + raise NotImplementedError + + def add_to_surname_list(self, person, batch_transaction, name): + """ + Add surname from given person to list of surnames + """ + raise NotImplementedError + + def build_surname_list(self): + """ + Build the list of locale-sorted surnames contained in the database. + """ + raise NotImplementedError + + def commit_base(self, obj, data_map, key, transaction, change_time): + """ + Commit the specified object to the database, storing the changes as + part of the transaction. + """ + raise NotImplementedError + + def commit_event(self, event, transaction, change_time=None): + """ + Commit the specified Event to the database, storing the changes as + part of the transaction. + """ + raise NotImplementedError + + def commit_family(self, family, transaction, change_time=None): + """ + Commit the specified Family to the database, storing the changes as + part of the transaction. + """ + raise NotImplementedError + + def commit_family_event(self, event, transaction, change_time=None): + """ + Commit the specified family Event to the database, storing the + changes as part of the transaction. + """ + raise NotImplementedError + + def commit_media_object(self, obj, transaction, change_time=None): + """ + Commit the specified MediaObject to the database, storing the changes + as part of the transaction. + """ + raise NotImplementedError + + def commit_note(self, note, transaction, change_time=None): + """ + Commit the specified Note to the database, storing the changes as part + of the transaction. + """ + raise NotImplementedError + + def commit_person(self, person, transaction, change_time=None): + """ + Commit the specified Person to the database, storing the changes as + part of the transaction. + """ + raise NotImplementedError + + def commit_personal_event(self, event, transaction, change_time=None): + """ + Commit the specified personal Event to the database, storing the + changes as part of the transaction. + """ + raise NotImplementedError + + def commit_place(self, place, transaction, change_time=None): + """ + Commit the specified Place to the database, storing the changes as + part of the transaction. + """ + raise NotImplementedError + + def commit_repository(self, repository, transaction, change_time=None): + """ + Commit the specified Repository to the database, storing the changes + as part of the transaction. + """ + raise NotImplementedError + + def commit_source(self, source, transaction, change_time=None): + """ + Commit the specified Source to the database, storing the changes as + part of the transaction. + """ + raise NotImplementedError + + def delete_primary_from_reference_map(self, handle, transaction): + """ + Called each time an object is removed from the database. + + This can be used by subclasses to update any additional index tables + that might need to be changed. + """ + raise NotImplementedError + + def need_upgrade(self): + """ + Return True if database needs to be upgraded + """ + raise NotImplementedError + + def rebuild_secondary(self, callback): + """ + Rebuild secondary indices + """ + raise NotImplementedError + + def reindex_reference_map(self, callback): + """ + Reindex all primary records in the database. + """ + raise NotImplementedError + + def remove_event(self, handle, transaction): + """ + Remove the Event specified by the database handle from the + database, preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_family(self, handle, transaction): + """ + Remove the Family specified by the database handle from the + database, preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_from_surname_list(self, person): + """ + Check whether there are persons with the same surname left in + the database. + + If not then we need to remove the name from the list. + The function must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_note(self, handle, transaction): + """ + Remove the Note specified by the database handle from the + database, preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_object(self, handle, transaction): + """ + Remove the MediaObjectPerson specified by the database handle from the + database, preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_person(self, handle, transaction): + """ + Remove the Person specified by the database handle from the database, + preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_place(self, handle, transaction): + """ + Remove the Place specified by the database handle from the + database, preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_repository(self, handle, transaction): + """ + Remove the Repository specified by the database handle from the + database, preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def remove_source(self, handle, transaction): + """ + Remove the Source specified by the database handle from the + database, preserving the change in the passed transaction. + + This method must be overridden in the derived class. + """ + raise NotImplementedError + + def set_auto_remove(self): + """ + BSDDB change log settings using new method with renamed attributes + """ + raise NotImplementedError + + def set_default_person_handle(self, handle): + """ + Set the default Person to the passed instance. + """ + raise NotImplementedError + + def set_name_group_mapping(self, name, group): + """ + Set the default grouping name for a surname. + + Needs to be overridden in the derived class. + """ + raise NotImplementedError + + def sort_surname_list(self): + """ + Sort the list of surnames contained in the database by locale ordering. + """ + raise NotImplementedError + + def transaction_begin(self, msg='', batch=False, no_magic=False): + """ + Create a new Transaction tied to the current UNDO database. + + The transaction has no effect until it is committed using the + transaction_commit function of the this database object. + """ + raise NotImplementedError + + def transaction_commit(self, transaction, msg): + """ + Commit the transaction to the associated UNDO database. + """ + raise NotImplementedError + + def update_reference_map(self, obj, transaction): + """ + Called each time an object is writen to the database. + + This can be used by subclasses to update any additional index tables + that might need to be changed. + """ + raise NotImplementedError + + def write_version(self, name): + """ + Write version number for a newly created DB. """ raise NotImplementedError @@ -1531,7 +1540,7 @@ class GrampsDbBase(object): cref.ref = child.handle cref.set_father_relation(frel) cref.set_mother_relation(mrel) - + family.add_child_ref(cref) child.add_parent_family_handle(family.handle) @@ -1546,7 +1555,7 @@ class GrampsDbBase(object): if need_commit: self.transaction_commit(trans, _('Add child to family') ) - + def remove_child_from_family(self, person_handle, family_handle, trans=None): """ Remove a person as a child of the family, deleting the family if @@ -1562,7 +1571,7 @@ class GrampsDbBase(object): trans = self.transaction_begin() else: need_commit = False - + child_list = family.get_child_ref_list() if (not family.get_father_handle() and not family.get_mother_handle() and len(child_list) <= 1): @@ -1574,10 +1583,10 @@ class GrampsDbBase(object): else: self.commit_family(family, trans) self.commit_person(person, trans) - + if need_commit: self.transaction_commit(trans,_("Remove child from family")) - + def delete_person_from_database(self, person, trans): """ Deletes a person from the database, cleaning up all associated references. @@ -1620,7 +1629,7 @@ class GrampsDbBase(object): p.remove_handle_references('Person', handle) self.commit_person(person, trans) self.remove_person(handle, trans) - + def remove_family_relationships(self, family_handle, trans=None): """ Remove a family and its relationships. @@ -1647,10 +1656,10 @@ class GrampsDbBase(object): self.commit_person(person, trans) self.remove_family(family_handle, trans) - + if need_commit: self.transaction_commit(trans, _("Remove Family")) - + def remove_parent_from_family(self, person_handle, family_handle, trans=None): """ Remove a person as either the father or mother of a family, @@ -1684,10 +1693,10 @@ class GrampsDbBase(object): else: self.commit_family(family, trans) self.commit_person(person, trans) - + if need_commit: self.transaction_commit(trans,msg) - + def marriage_from_eventref_list(self, eventref_list): """ Get the marriage event from an eventref list. @@ -1697,7 +1706,7 @@ class GrampsDbBase(object): if event and event.type.is_marriage(): return event return None - + def get_total(self): """ Get the total of primary objects. @@ -1709,10 +1718,10 @@ class GrampsDbBase(object): place_len = self.get_number_of_places() repo_len = self.get_number_of_repositories() obj_len = self.get_number_of_media_objects() - + return person_len + family_len + event_len + \ place_len + source_len + obj_len + repo_len - + def set_birth_death_index(self, person): """ Set the birth and death indices for a person. @@ -1734,4 +1743,4 @@ class GrampsDbBase(object): person.birth_ref_index = birth_ref_index person.death_ref_index = death_ref_index - + diff --git a/src/gen/db/dbconst.py b/src/gen/db/dbconst.py index 93eb88e2a..f4d89323f 100644 --- a/src/gen/db/dbconst.py +++ b/src/gen/db/dbconst.py @@ -59,7 +59,7 @@ DBEXT = ".db" # File extension to be used for database files DBUNDOFN = "undo.db" # File name of 'undo' database DBLOCKFN = "lock" # File name of lock file DBRECOVFN = "need_recover" # File name of recovery file -DBLOGNAME = ".GrampsDb" # Name of logger +DBLOGNAME = ".Db" # Name of logger DBMODE_R = "r" # Read-only access DBMODE_W = "w" # Full Reaw/Write access DBPAGE = 16384 # Size of the pages used to hold items in the database diff --git a/src/gen/db/exceptions.py b/src/gen/db/exceptions.py index be2e1443d..ea71cda3b 100644 --- a/src/gen/db/exceptions.py +++ b/src/gen/db/exceptions.py @@ -20,7 +20,7 @@ # $Id:exceptions.py 9912 2008-01-22 09:17:46Z acraphae $ -"""Exceptions generated by the GrampsDb package.""" +"""Exceptions generated by the Db package.""" #------------------------------------------------------------------------- # @@ -30,7 +30,7 @@ from gettext import gettext as _ -class GrampsDbException(Exception): +class DbException(Exception): def __init__(self, value): Exception.__init__(self) @@ -39,7 +39,7 @@ class GrampsDbException(Exception): def __str__(self): return self.value -class GrampsDbWriteFailure(Exception): +class DbWriteFailure(Exception): """ Error used to indicate that a write to a database has failed. """ @@ -54,7 +54,7 @@ class GrampsDbWriteFailure(Exception): def messages(self): return self.value, self.value2 -class GrampsDbVersionError(Exception): +class DbVersionError(Exception): """ Error used to report that a file could not be read because it is written in an unsupported version of the file format. @@ -67,7 +67,7 @@ class GrampsDbVersionError(Exception): "Gramps.\nPlease upgrade to the corresponding version or use " "XML for porting data between different database versions.") -class GrampsDbUpgradeRequiredError(Exception): +class DbUpgradeRequiredError(Exception): """ Error used to report that a database needs to be upgraded before it can be used. diff --git a/src/gen/db/iterator.py b/src/gen/db/iterator.py index 1490ec9fe..362e2fff6 100644 --- a/src/gen/db/iterator.py +++ b/src/gen/db/iterator.py @@ -46,7 +46,7 @@ class CursorIterator(object): # check for cancel #if self._status.should_cancel(): - # raise GrampsDbUserCancel + # raise DbUserCancel # emit heartbeat self._status.heartbeat() diff --git a/src/gen/db/read.py b/src/gen/db/read.py index be489798e..2906bba81 100644 --- a/src/gen/db/read.py +++ b/src/gen/db/read.py @@ -49,7 +49,7 @@ from gen.lib import (MediaObject, Person, Family, Source, Event, Place, Repository, Note, GenderStats, Researcher) from gen.db.dbconst import * from gen.utils.callback import Callback -from gen.db import (GrampsCursor, GrampsDbBase) +from gen.db import (GrampsCursor, DbReadBase) from Utils import create_id import Errors import config @@ -68,7 +68,7 @@ _SIGBASE = ('person', 'family', 'source', 'event', DBERRS = (db.DBRunRecoveryError, db.DBAccessError, db.DBPageNotFoundError, db.DBInvalidArgError) -class GrampsDbBookmarks(object): +class DbBookmarks(object): def __init__(self, default=[]): self.bookmarks = list(default) # want a copy (not an alias) @@ -98,14 +98,14 @@ class GrampsDbBookmarks(object): # GrampsDBReadCursor # #------------------------------------------------------------------------- -class GrampsDbReadCursor(GrampsCursor): +class DbReadCursor(GrampsCursor): def __init__(self, source, txn=None, **kwargs): GrampsCursor.__init__(self, txn=txn, **kwargs) self.cursor = source.db.cursor(txn) self.source = source -class GrampsDbRead(GrampsDbBase, Callback): +class DbBsddbRead(DbReadBase, Callback): """ Read class for the GRAMPS databases. Implements methods necessary to read the various object classes. Currently, there are eight (8) classes: @@ -176,10 +176,10 @@ class GrampsDbRead(GrampsDbBase, Callback): def __init__(self): """ - Create a new GrampsDbRead instance. + Create a new DbBsddbRead instance. """ - GrampsDbBase.__init__(self) + DbReadBase.__init__(self) #Callback.__init__(self) self.set_person_id_prefix('I%04d') @@ -253,14 +253,14 @@ class GrampsDbRead(GrampsDbBase, Callback): self.default = None self.owner = Researcher() self.name_formats = [] - self.bookmarks = GrampsDbBookmarks() - self.family_bookmarks = GrampsDbBookmarks() - self.event_bookmarks = GrampsDbBookmarks() - self.place_bookmarks = GrampsDbBookmarks() - self.source_bookmarks = GrampsDbBookmarks() - self.repo_bookmarks = GrampsDbBookmarks() - self.media_bookmarks = GrampsDbBookmarks() - self.note_bookmarks = GrampsDbBookmarks() + self.bookmarks = DbBookmarks() + self.family_bookmarks = DbBookmarks() + self.event_bookmarks = DbBookmarks() + self.place_bookmarks = DbBookmarks() + self.source_bookmarks = DbBookmarks() + self.repo_bookmarks = DbBookmarks() + self.media_bookmarks = DbBookmarks() + self.note_bookmarks = DbBookmarks() self._bm_changes = 0 self.path = "" self.surname_list = [] @@ -284,7 +284,7 @@ class GrampsDbRead(GrampsDbBase, Callback): def get_cursor(self, table, *args, **kwargs): try: - return GrampsDbReadCursor(table, self.txn) + return DbReadCursor(table, self.txn) except DBERRS, msg: self.__log_error() raise Errors.DbError(msg) @@ -313,14 +313,6 @@ class GrampsDbRead(GrampsDbBase, Callback): def get_note_cursor(self, *args, **kwargs): return self.get_cursor(self.note_map, *args, **kwargs) - def load(self, name, callback, mode=DBMODE_R, upgrade=False): - """ - Open the specified database. - - The method needs to be overridden in the derived class. - """ - raise NotImplementedError - def close(self): """ Close the specified database. @@ -608,14 +600,6 @@ class GrampsDbRead(GrampsDbBase, Callback): """ return self.name_group.has_key(str(name)) - def set_name_group_mapping(self, name, group): - """ - Set the default grouping name for a surname. - - Needs to be overridden in the derived class. - """ - raise NotImplementedError - def get_number_of_records(self, table): if not self.db_is_open: return 0 @@ -991,40 +975,6 @@ class GrampsDbRead(GrampsDbBase, Callback): """ return self.surname_list - def build_surname_list(self): - """ - Build the list of locale-sorted surnames contained in the database. - - The function must be overridden in the derived class. - """ - raise NotImplementedError - - def sort_surname_list(self): - """ - Sort the surname list in place. - """ - raise NotImplementedError - - def add_to_surname_list(self, person, batch_transaction): - """ - Check to see if the surname of the given person is already in - the surname list. - - If not then we need to add the name to the list. - The function must be overridden in the derived class. - """ - raise NotImplementedError - - def remove_from_surname_list(self, person): - """ - Check whether there are persons with the same surname left in - the database. - - If not then we need to remove the name from the list. - The function must be overridden in the derived class. - """ - raise NotImplementedError - def get_bookmarks(self): """Return the list of Person handles in the bookmarks.""" return self.bookmarks @@ -1466,15 +1416,6 @@ class GrampsDbRead(GrampsDbBase, Callback): """ return self.__get_columns(NOTE_COL_KEY) - def delete_primary_from_reference_map(self, handle, transaction): - """ - Called each time an object is removed from the database. - - This can be used by subclasses to update any additional index tables - that might need to be changed. - """ - pass - def find_backlink_handles(self, handle, include_classes=None): """ Find all objects that hold a reference to the object handle. @@ -1557,8 +1498,3 @@ class GrampsDbRead(GrampsDbBase, Callback): """ return self._bm_changes > 0 -if __name__ == '__main__': - x = GrampsDbRead() - x.person_prefix = 'foo %s bar' - print x.person_prefix - diff --git a/src/gen/db/test/db_test.py b/src/gen/db/test/db_test.py new file mode 100644 index 000000000..9231dc488 --- /dev/null +++ b/src/gen/db/test/db_test.py @@ -0,0 +1,268 @@ +from gen.db import (DbReadBase, DbWriteBase, + DbBsddbRead, DbBsddb) +from gen.proxy.proxybase import ProxyDbBase +from gen.proxy import LivingProxyDb + +class DbTest(object): + READ_METHODS = [ + "all_handles", + "close", + "create_id", + "db_has_bm_changes", + "find_backlink_handles", + "find_initial_person", + "find_next_event_gramps_id", + "find_next_family_gramps_id", + "find_next_note_gramps_id", + "find_next_object_gramps_id", + "find_next_person_gramps_id", + "find_next_place_gramps_id", + "find_next_repository_gramps_id", + "find_next_source_gramps_id", + "get_bookmarks", + "get_child_column_order", + "get_child_reference_types", + "get_default_handle", + "get_default_person", + "get_event_bookmarks", + "get_event_column_order", + "get_event_cursor", + "get_event_from_gramps_id", + "get_event_from_handle", + "get_event_handles", + "get_event_roles", + "get_family_attribute_types", + "get_family_bookmarks", + "get_family_cursor", + "get_family_event_types", + "get_family_from_gramps_id", + "get_family_from_handle", + "get_family_handles", + "get_family_list_column_order", + "get_family_relation_types", + "get_from_handle", + "get_gramps_ids", + "get_marker_types", + "get_media_attribute_types", + "get_media_bookmarks", + "get_media_column_order", + "get_media_cursor", + "get_media_object_handles", + "get_mediapath", + "get_name_group_keys", + "get_name_group_mapping", + "get_name_types", + "get_note_bookmarks", + "get_note_column_order", + "get_note_cursor", + "get_note_from_gramps_id", + "get_note_from_handle", + "get_note_handles", + "get_note_types", + "get_number_of_events", + "get_number_of_families", + "get_number_of_media_objects", + "get_number_of_notes", + "get_number_of_people", + "get_number_of_places", + "get_number_of_repositories", + "get_number_of_sources", + "get_object_from_gramps_id", + "get_object_from_handle", + "get_person_attribute_types", + "get_person_column_order", + "get_person_cursor", + "get_person_event_types", + "get_person_from_gramps_id", + "get_person_from_handle", + "get_person_handles", + "get_place_bookmarks", + "get_place_column_order", + "get_place_cursor", + "get_place_from_gramps_id", + "get_place_from_handle", + "get_place_handles", + "get_raw_event_data", + "get_raw_family_data", + "get_raw_note_data", + "get_raw_object_data", + "get_raw_person_data", + "get_raw_place_data", + "get_raw_repository_data", + "get_raw_source_data", + "get_reference_map_cursor", + "get_reference_map_primary_cursor", + "get_reference_map_referenced_cursor", + "get_repo_bookmarks", + "get_repository_column_order", + "get_repository_cursor", + "get_repository_from_gramps_id", + "get_repository_from_handle", + "get_repository_handles", + "get_repository_types", + "get_researcher", + "get_save_path", + "get_source_bookmarks", + "get_source_column_order", + "get_source_cursor", + "get_source_from_gramps_id", + "get_source_from_handle", + "get_source_handles", + "get_source_media_types", + "get_surname_list", + "get_url_types", + "gramps_upgrade", + "has_event_handle", + "has_family_handle", + "has_gramps_id", + "has_name_group_key", + "has_note_handle", + "has_object_handle", + "has_person_handle", + "has_place_handle", + "has_repository_handle", + "has_source_handle", + "is_open", + "iter_event_handles", + "iter_events", + "iter_families", + "iter_family_handles", + "iter_media_object_handles", + "iter_media_objects", + "iter_note_handles", + "iter_notes", + "iter_people", + "iter_person_handles", + "iter_place_handles", + "iter_places", + "iter_repositories", + "iter_repository_handles", + "iter_source_handles", + "iter_sources", + "load", + "report_bm_change", + "request_rebuild", + # Prefix: + "set_event_id_prefix", + "set_family_id_prefix", + "set_note_id_prefix", + "set_object_id_prefix", + "set_person_id_prefix", + "set_place_id_prefix", + "set_prefixes", + "set_repository_id_prefix", + "set_source_id_prefix", + # Column order: + "set_child_column_order", + "set_column_order", + "set_event_column_order", + "set_family_list_column_order", + "set_media_column_order", + "set_note_column_order", + "set_person_column_order", + "set_place_column_order", + "set_repository_column_order", + "set_source_column_order", + # Other set methods: + "set_mediapath", + "set_redo_callback", + "set_researcher", + "set_save_path", + "set_undo_callback", + + "version_supported", + ] + + WRITE_METHODS = [ + "add_event", + "add_family", + "add_family_event", + "add_note", + "add_object", + "add_person", + "add_person_event", + "add_place", + "add_repository", + "add_source", + "add_to_surname_list", + "build_surname_list", + "commit_base", + "commit_event", + "commit_family", + "commit_family_event", + "commit_media_object", + "commit_note", + "commit_person", + "commit_personal_event", + "commit_place", + "commit_repository", + "commit_source", + "delete_primary_from_reference_map", + "need_upgrade", + "rebuild_secondary", + "reindex_reference_map", + "remove_event", + "remove_family", + "remove_from_surname_list", + "remove_note", + "remove_object", + "remove_person", + "remove_place", + "remove_repository", + "remove_source", + "set_auto_remove", + "set_default_person_handle", + "set_name_group_mapping", + "sort_surname_list", + "transaction_begin", + "transaction_commit", + "update_reference_map", + "write_version", + ] + + def __init__(self, db): + self.db = db + + def _verify_readonly(self): + print "Verifying readonly", self.db.__class__.__name__ + for method in self.READ_METHODS: + assert hasattr(self.db, method), \ + ("readonly should have a '%s' method" % method) + for method in self.WRITE_METHODS: + assert not hasattr(self.db, method), \ + ("readonly should NOT have a '%s' method" % method) + print "passed!" + + def _verify_readwrite(self): + print "Verifying readwrite", self.db.__class__.__name__ + for method in self.READ_METHODS: + assert hasattr(self.db, method), \ + ("readwrite should have a '%s' method" % method) + for method in self.WRITE_METHODS: + assert hasattr(self.db, method), \ + ("readwrite should have a '%s' method" % method) + print "passed!" + +db1 = DbTest(DbReadBase()) +db1._verify_readonly() + +db2 = DbTest(DbWriteBase()) +db2._verify_readwrite() + +from gen.db import DbBsddbRead +db3 = DbTest(DbBsddbRead()) +db3._verify_readonly() + +from gen.db import DbBsddb +db4 = DbTest(DbBsddb()) +db4._verify_readwrite() + +from gen.proxy.proxybase import ProxyDbBase +gdb = DbBsddb() +db5 = DbTest(ProxyDbBase(gdb)) +db5._verify_readonly() + +from gen.proxy import LivingProxyDb +gdb = DbBsddb() +db6 = DbTest(LivingProxyDb(gdb, LivingProxyDb.MODE_EXCLUDE_ALL)) +db6._verify_readonly() diff --git a/src/gen/db/txn.py b/src/gen/db/txn.py index 60f91c7f4..862bb7c80 100644 --- a/src/gen/db/txn.py +++ b/src/gen/db/txn.py @@ -21,7 +21,7 @@ # $Id$ """ -Exports the GrampsDbTxn class for managing Gramps transactions and the undo +Exports the DbTxn class for managing Gramps transactions and the undo database. """ @@ -51,7 +51,7 @@ _LOG = logging.getLogger(DBLOGNAME) # Gramps transaction class # #------------------------------------------------------------------------- -class GrampsDbTxn(dict): +class DbTxn(dict): """ Define a group of database commits that define a single logical operation. This class should not be used directly, but subclassed to reference a real @@ -86,10 +86,10 @@ class GrampsDbTxn(dict): Create a new transaction. A Transaction instance should not be created directly, but by the - GrampsDbBase class or classes derived from GrampsDbBase. The commitdb + DbBase class or classes derived from DbBase. The commitdb parameter is a list-like interface that stores the commit data. This could be a simple list, or a RECNO-style database object. The grampsdb - parameter is a reference to the GrampsDbWrite object to which this + parameter is a reference to the DbWrite object to which this transaction will be applied. The data structure used to handle the transactions is a Python @@ -108,7 +108,7 @@ class GrampsDbTxn(dict): data = pickled representation of the object """ - super(GrampsDbTxn, self).__init__({}) + super(DbTxn, self).__init__({}) self.msg = msg self.commitdb = commitdb @@ -298,7 +298,7 @@ def testtxn(): """ Fake commit database""" pass - class G(GrampsDbTxn): + class G(DbTxn): """Derived transacton class""" def get_db_txn(self, env): return T() diff --git a/src/gen/db/undoredo.py b/src/gen/db/undoredo.py index 035834365..5f37cbdb2 100644 --- a/src/gen/db/undoredo.py +++ b/src/gen/db/undoredo.py @@ -21,7 +21,7 @@ # $Id$ """ -Exports the GrampsDbUndo class for managing Gramps transactions +Exports the DbUndo class for managing Gramps transactions undos and redos. """ @@ -57,10 +57,10 @@ _SIGBASE = ('person', 'family', 'source', 'event', 'media', 'place', 'repository', 'reference', 'note') #------------------------------------------------------------------------- # -# GrampsDbUndo class +# DbUndo class # #------------------------------------------------------------------------- -class GrampsDbUndo(object): +class DbUndo(object): """ Base class for the gramps undo/redo manager. Needs to be subclassed for use with a real backend. @@ -333,7 +333,7 @@ class GrampsDbUndo(object): self.db._log_error() raise Errors.DbError(msg) -class GrampsDbUndoList(GrampsDbUndo): +class DbUndoList(DbUndo): """ Implementation of the gramps undo database using a Python list """ @@ -341,7 +341,7 @@ class GrampsDbUndoList(GrampsDbUndo): """ Class constructor """ - super(GrampsDbUndoList, self).__init__(grampsdb) + super(DbUndoList, self).__init__(grampsdb) self.undodb = [] def open(self): @@ -389,7 +389,7 @@ class GrampsDbUndoList(GrampsDbUndo): """ return len(self.undodb) -class GrampsDbUndoBSDDB(GrampsDbUndo): +class DbUndoBSDDB(DbUndo): """ Class constructor for gramps undo/redo database using a bsddb recno database as the backing store. @@ -399,7 +399,7 @@ class GrampsDbUndoBSDDB(GrampsDbUndo): """ Class constructor """ - super(GrampsDbUndoBSDDB, self).__init__(grampsdb) + super(DbUndoBSDDB, self).__init__(grampsdb) self.undodb = db.DB() self.path = path @@ -478,7 +478,7 @@ def testundo(): self.reference_map = {} print "list tests" - undo = GrampsDbUndoList(D()) + undo = DbUndoList(D()) print undo.append('foo') print undo.append('bar') print undo[0] @@ -490,7 +490,7 @@ def testundo(): print data print print "bsddb tests" - undo = GrampsDbUndoBSDDB(D(), '/tmp/testundo') + undo = DbUndoBSDDB(D(), '/tmp/testundo') undo.open() print undo.append('foo') print undo.append('fo2') diff --git a/src/gen/db/write.py b/src/gen/db/write.py index 5228eb0e6..6a66c061e 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -21,7 +21,7 @@ # $Id$ """ -Provide the Berkeley DB (DBDir) database backend for GRAMPS. +Provide the Berkeley DB (DbBsddb) database backend for GRAMPS. This is used since GRAMPS version 3.0 """ @@ -50,9 +50,10 @@ from sys import maxint #------------------------------------------------------------------------- from gen.lib import (GenderStats, Person, Family, Event, Place, Source, MediaObject, Repository, Note) -from gen.db import (GrampsDbRead, BSDDBTxn, GrampsDbTxn, GrampsCursor, - GrampsDbVersionError, GrampsDbUpgradeRequiredError, - GrampsDbUndoBSDDB as GrampsDbUndo) +from gen.db import (DbBsddbRead, DbWriteBase, BSDDBTxn, + DbTxn, GrampsCursor,DbVersionError, + DbUpgradeRequiredError, + DbUndoBSDDB as DbUndo) from gen.db.dbconst import * from gen.utils.callback import Callback from BasicUtils import UpdateCallback @@ -151,10 +152,10 @@ class GrampsWriteCursor(GrampsCursor): #------------------------------------------------------------------------- # -# GrampsDBDirAssocCursor +# DbBsddbAssocCursor # #------------------------------------------------------------------------- -class GrampsDBDirAssocCursor(GrampsCursor): +class DbBsddbAssocCursor(GrampsCursor): def __init__(self, source, txn=None, **kwargs): GrampsCursor.__init__(self, txn=txn, **kwargs) @@ -163,10 +164,11 @@ class GrampsDBDirAssocCursor(GrampsCursor): #------------------------------------------------------------------------- # -# GrampsDBDir +# DbBsddb # #------------------------------------------------------------------------- -class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): +class DbBsddb(DbBsddbRead, DbWriteBase, + Callback, UpdateCallback): """ GRAMPS database write access object. """ @@ -197,7 +199,7 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): """Create a new GrampsDB.""" self.txn = None - GrampsDbRead.__init__(self) + DbBsddbRead.__init__(self) Callback.__init__(self) self.secondary_connected = False self.has_changed = False @@ -279,14 +281,14 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): """ Returns a reference to a cursor over the reference map """ - return GrampsDBDirAssocCursor(self.reference_map, self.txn) + return DbBsddbAssocCursor(self.reference_map, self.txn) @catch_db_error def get_reference_map_primary_cursor(self): """ Returns a reference to a cursor over the reference map primary map """ - return GrampsDBDirAssocCursor(self.reference_map_primary_map, + return DbBsddbAssocCursor(self.reference_map_primary_map, self.txn) @catch_db_error @@ -294,10 +296,10 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): """ Returns a reference to a cursor over the reference map referenced map """ - return GrampsDBDirAssocCursor(self.reference_map_referenced_map, + return DbBsddbAssocCursor(self.reference_map_referenced_map, self.txn) - # These are overriding the GrampsDbRead's methods of saving metadata + # These are overriding the DbBsddbRead's methods of saving metadata # because we now have txn-capable metadata table @catch_db_error @@ -376,7 +378,7 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): self.close() self.readonly = mode == DBMODE_R - #super(GrampsDbRead, self).load(name, callback, mode) + #super(DbBsddbRead, self).load(name, callback, mode) if callback: callback(12) @@ -419,7 +421,7 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): # it makes no sense to go further if not self.version_supported(): self.__close_early() - raise GrampsDbVersionError() + raise DbVersionError() self.__load_metadata() gstats = self.metadata.get('gender_stats', default=None) @@ -473,7 +475,7 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): self.gramps_upgrade(callback) else: self.__close_early() - raise GrampsDbUpgradeRequiredError() + raise DbUpgradeRequiredError() if callback: callback(50) @@ -501,7 +503,7 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): """ if not self.readonly: self.undolog = os.path.join(self.full_name, DBUNDOFN) - self.undodb = GrampsDbUndo(self, self.undolog) + self.undodb = DbUndo(self, self.undolog) self.undodb.open() def __close_undodb(self): @@ -1719,7 +1721,7 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): # BdbTransaction # #------------------------------------------------------------------------- -class BdbTransaction(GrampsDbTxn): +class BdbTransaction(DbTxn): """ The batch parameter is set to True for large transactions. For such transactions, the list of changes is not maintained, and no undo @@ -1735,7 +1737,7 @@ class BdbTransaction(GrampsDbTxn): __slots__ = ('batch', 'no_magic') def __init__(self, msg, undodb, grampsdb, batch=False, no_magic=False): - GrampsDbTxn.__init__(self, msg, undodb, grampsdb) + DbTxn.__init__(self, msg, undodb, grampsdb) self.batch = batch self.no_magic = no_magic @@ -1774,7 +1776,7 @@ if __name__ == "__main__": import os, sys, pdb - d = GrampsDBDir() + d = DbBsddb() if len(sys.argv) > 1: db_name = sys.argv[1] else: diff --git a/src/gen/proxy/private.py b/src/gen/proxy/private.py index 6a1d6adbe..2ed77ed69 100644 --- a/src/gen/proxy/private.py +++ b/src/gen/proxy/private.py @@ -416,7 +416,7 @@ def copy_media_ref_list(db, original_obj, clean_obj): references and references to private objects. @param db: GRAMPS database to which the references belongs - @type db: GrampsDbBase + @type db: DbBase @param original_obj: Object that may have private references @type original_obj: MediaBase @param clean_obj: Object that will have only non-private references @@ -436,7 +436,7 @@ def copy_source_ref_list(db, original_obj, clean_obj): references and references to private objects. @param db: GRAMPS database to which the references belongs - @type db: GrampsDbBase + @type db: DbBase @param original_obj: Object that may have private references @type original_obj: SourceBase @param clean_obj: Object that will have only non-private references @@ -456,7 +456,7 @@ def copy_notes(db, original_obj, clean_obj): notes. @param db: GRAMPS database to which the references belongs - @type db: GrampsDbBase + @type db: DbBase @param original_obj: Object that may have private references @type original_obj: NoteBase @param clean_obj: Object that will have only non-private references @@ -474,7 +474,7 @@ def copy_attributes(db, original_obj, clean_obj): private attributes. @param db: GRAMPS database to which the references belongs - @type db: GrampsDbBase + @type db: DbBase @param original_obj: Object that may have private references @type original_obj: AttributeBase @param clean_obj: Object that will have only non-private references @@ -496,7 +496,7 @@ def copy_urls(db, original_obj, clean_obj): private urls. @param db: GRAMPS database to which the references belongs - @type db: GrampsDbBase + @type db: DbBase @param original_obj: Object that may have urls @type original_obj: UrlBase @param clean_obj: Object that will have only non-private urls @@ -513,7 +513,7 @@ def copy_lds_ords(db, original_obj, clean_obj): private LDS ORDs. @param db: GRAMPS database to which the references belongs - @type db: GrampsDbBase + @type db: DbBase @param original_obj: Object that may have LDS ORDs @type original_obj: LdsOrdBase @param clean_obj: Object that will have only non-private LDS ORDs @@ -530,7 +530,7 @@ def copy_addresses(db, original_obj, clean_obj): private addresses. @param db: GRAMPS database to which the references belongs - @type db: GrampsDbBase + @type db: DbBase @param original_obj: Object that may have addresses @type original_obj: AddressBase @param clean_obj: Object that will have only non-private addresses @@ -548,7 +548,7 @@ def sanitize_lds_ord(db, lds_ord): removed from it. @param db: GRAMPS database to which the LdsOrd object belongs - @type db: GrampsDbBase + @type db: DbBase @param name: source LdsOrd object that will be copied with privacy records removed @type name: LdsOrd @@ -584,7 +584,7 @@ def sanitize_address(db, address): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param name: source Address object that will be copied with privacy records removed @type name: Address @@ -614,7 +614,7 @@ def sanitize_name(db, name): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param name: source Name object that will be copied with privacy records removed @type name: Name @@ -647,7 +647,7 @@ def sanitize_media_ref(db, media_ref): removed from it. @param db: GRAMPS database to which the MediaRef object belongs - @type db: GrampsDbBase + @type db: DbBase @param source_ref: source MediaRef object that will be copied with privacy records removed @type source_ref: MediaRef @@ -671,7 +671,7 @@ def sanitize_source_ref(db, source_ref): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param source_ref: source SourceRef object that will be copied with privacy records removed @type source_ref: SourceRef @@ -694,7 +694,7 @@ def sanitize_event_ref(db, event_ref): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param event_ref: source EventRef object that will be copied with privacy records removed @type event_ref: EventRef @@ -717,7 +717,7 @@ def sanitize_person(db, person): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param person: source Person object that will be copied with privacy records removed @type person: Person @@ -806,7 +806,7 @@ def sanitize_source(db, source): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param source: source Source object that will be copied with privacy records removed @type source: Source @@ -844,7 +844,7 @@ def sanitize_media(db, media): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param media: source Media object that will be copied with privacy records removed @type media: MediaObject @@ -875,7 +875,7 @@ def sanitize_place(db, place): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param place: source Place object that will be copied with privacy records removed @type place: Place @@ -908,7 +908,7 @@ def sanitize_event(db, event): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param event: source Event object that will be copied with privacy records removed @type event: Event @@ -944,7 +944,7 @@ def sanitize_family(db, family): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param family: source Family object that will be copied with privacy records removed @type family: Family @@ -1012,7 +1012,7 @@ def sanitize_repository(db, repository): removed from it. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param repository: source Repository object that will be copied with privacy records removed @type repository: Repository diff --git a/src/gen/proxy/proxybase.py b/src/gen/proxy/proxybase.py index 001000f28..c1f19775c 100644 --- a/src/gen/proxy/proxybase.py +++ b/src/gen/proxy/proxybase.py @@ -30,15 +30,16 @@ Proxy class for the GRAMPS databases. Filter out all data marked private. # #------------------------------------------------------------------------- from itertools import ifilter +import types #------------------------------------------------------------------------- # # GRAMPS libraries # #------------------------------------------------------------------------- -from gen.db.base import GrampsDbBase +from gen.db.base import DbReadBase, DbWriteBase -class ProxyDbBase(GrampsDbBase): +class ProxyDbBase(DbReadBase): """ ProxyDbBase is a base class for building a proxy to a Gramps database. This class attempts to implement functions that are likely to be common @@ -323,8 +324,12 @@ class ProxyDbBase(GrampsDbBase): setattr(self, name, attr) return attr + # if a write-method: + if (name in DbWriteBase.__dict__ and + not name.startswith("__") and + type(DbWriteBase.__dict__[name]) is types.FunctionType): + raise AttributeError # Default behaviour: lookup attribute in parent object - return getattr(self.db, name) def get_person_from_handle(self, handle): @@ -678,29 +683,6 @@ class ProxyDbBase(GrampsDbBase): """returns the default media path of the database""" return self.db.get_mediapath() - def find_backlink_handles(self, handle, include_classes=None): - """ - Find all objects that hold a reference to the object handle. - Returns an iterator over a list of (class_name, handle) tuples. - - @param handle: handle of the object to search for. - @type handle: database handle - @param include_classes: list of class names to include in the results. - Default: None means include all classes. - @type include_classes: list of class names - - This default implementation does a sequential scan through all - the primary object databases and is very slow. Backends can - override this method to provide much faster implementations that - make use of additional capabilities of the backend. - - Note that this is a generator function, it returns a iterator for - use in loops. If you want a list of the results use: - - > result_list = list(find_backlink_handles(handle)) - """ - raise NotImplementedError - def get_gramps_ids(self, obj_key): return self.db.get_gramps_ids(obj_key) diff --git a/src/gen/utils/callman.py b/src/gen/utils/callman.py index 7f80fb06c..df4e684f2 100644 --- a/src/gen/utils/callman.py +++ b/src/gen/utils/callman.py @@ -105,7 +105,7 @@ class CallbackManager(object): """ :param database: database to which to connect the callbacks of this CallbackManager object - :type database: a class:`~gen.db.base.GrampsDbBase` object + :type database: a class:`~gen.db.base.DbBase` object """ #no handles to track self.database = database @@ -261,7 +261,7 @@ class CallbackManager(object): Execute a specific callback. This is only actually done if one of the registered handles is involved. Arg must conform to the requirements of the signal emitter. - For a GrampsDbBase that is that arg must be not given (rebuild + For a DbBase that is that arg must be not given (rebuild methods), or arg[0] must be the list of handles affected. """ key = signal.split('-')[0] diff --git a/src/gui/dbloader.py b/src/gui/dbloader.py index b13a6b72d..d10f9210d 100644 --- a/src/gui/dbloader.py +++ b/src/gui/dbloader.py @@ -277,7 +277,7 @@ class DbLoader(CLIDbLoader): else: mode = 'w' - self.dbstate.change_database(gen.db.GrampsDBDir()) + self.dbstate.change_database(gen.db.DbBsddb()) self.dbstate.db.disable_signals() self._begin_progress() @@ -286,7 +286,7 @@ class DbLoader(CLIDbLoader): try: self.dbstate.db.load(filename, self._pulse_progress, mode, upgrade=False) - except gen.db.exceptions.GrampsDbUpgradeRequiredError, msg: + except gen.db.exceptions.DbUpgradeRequiredError, msg: if QuestionDialog2(_("Need to upgrade database!"), str(msg), _("Upgrade now"), @@ -296,7 +296,7 @@ class DbLoader(CLIDbLoader): self.dbstate.db.set_save_path(filename) else: self.dbstate.no_database() - except gen.db.exceptions.GrampsDbVersionError, msg: + except gen.db.exceptions.DbVersionError, msg: self.dbstate.no_database() self._errordialog( _("Cannot open database"), str(msg)) except OSError, msg: diff --git a/src/gui/dbman.py b/src/gui/dbman.py index 3375b2b98..83eb6c1cd 100644 --- a/src/gui/dbman.py +++ b/src/gui/dbman.py @@ -68,14 +68,14 @@ import pango # #------------------------------------------------------------------------- from QuestionDialog import ErrorDialog, QuestionDialog -from gen.db import GrampsDBDir +from gen.db import DbBsddb from gui.pluginmanager import GuiPluginManager from cli.clidbman import CLIDbManager, NAME_FILE, time_val from DdTargets import DdTargets import RecentFiles from glade import Glade from gen.db.backup import restore -from gen.db.exceptions import GrampsDbException +from gen.db.exceptions import DbException _RETURN = gtk.gdk.keyval_from_name("Return") _KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter") @@ -509,7 +509,7 @@ class DbManager(CLIDbManager): new_path, newname = self._create_new_db("%s : %s" % (parent_name, name)) self.__start_cursor(_("Extracting archive...")) - dbclass = GrampsDBDir + dbclass = DbBsddb dbase = dbclass() dbase.load(new_path, None) @@ -633,10 +633,10 @@ class DbManager(CLIDbManager): fname = os.path.join(dirname, filename) os.unlink(fname) - newdb = GrampsDBDir() + newdb = DbBsddb() newdb.write_version(dirname) - dbclass = GrampsDBDir + dbclass = DbBsddb dbase = dbclass() dbase.set_save_path(dirname) dbase.load(dirname, None) @@ -645,7 +645,7 @@ class DbManager(CLIDbManager): try: restore(dbase) - except GrampsDbException, msg: + except DbException, msg: ErrorDialog(_("Error restoring backup data"), msg) self.__end_cursor() diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index fe50a8edd..2647526a0 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -79,7 +79,7 @@ from gui.dbloader import DbLoader import GrampsDisplay from gen.utils import ProgressMonitor from gen.db.backup import backup -from gen.db.exceptions import GrampsDbException +from gen.db.exceptions import DbException from GrampsAboutDialog import GrampsAboutDialog import ProgressDialog @@ -700,7 +700,7 @@ class ViewManager(CLIManager): self.uistate.push_message(self.dbstate, _("Autobackup...")) try: backup(self.dbstate.db) - except GrampsDbException, msg: + except DbException, msg: ErrorDialog(_("Error saving backup data"), msg) self.uistate.set_busy_cursor(0) self.uistate.progress.hide() diff --git a/src/plugins/drawreport/StatisticsChart.py b/src/plugins/drawreport/StatisticsChart.py index ef9a7b8a8..c9fe9fb56 100644 --- a/src/plugins/drawreport/StatisticsChart.py +++ b/src/plugins/drawreport/StatisticsChart.py @@ -197,7 +197,7 @@ def estimate_age(db, person, end_handle=None, start_handle=None, today=_TODAY): the birth or death date is missing, a (-1, -1) is returned. @param db: GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @type db: DbBase @param person: Person object to calculate the age of @type person: Person @param end_handle: Determines the event handle that determines diff --git a/src/plugins/export/ExportXml.py b/src/plugins/export/ExportXml.py index 0e988303c..908856e4e 100644 --- a/src/plugins/export/ExportXml.py +++ b/src/plugins/export/ExportXml.py @@ -57,7 +57,7 @@ log = logging.getLogger(".WriteXML") #------------------------------------------------------------------------- import gen.lib from BasicUtils import UpdateCallback -from gen.db.exceptions import GrampsDbWriteFailure +from gen.db.exceptions import DbWriteFailure import const from QuestionDialog import ErrorDialog from ExportOptions import WriterOptionBox @@ -87,7 +87,7 @@ def escxml(d): # # #------------------------------------------------------------------------- -class GrampsDbXmlWriter(UpdateCallback): +class GrampsXmlWriter(UpdateCallback): """ Writes a database to the XML file. """ @@ -121,7 +121,7 @@ class GrampsDbXmlWriter(UpdateCallback): base = os.path.dirname(filename) if os.path.isdir(base): if not os.access(base, os.W_OK) or not os.access(base, os.R_OK): - raise GrampsDbWriteFailure( + raise DbWriteFailure( _('Failure writing %s') % filename, _("The database cannot be saved because you do " "not have permission to write to the directory. " @@ -131,7 +131,7 @@ class GrampsDbXmlWriter(UpdateCallback): if os.path.exists(filename): if not os.access(filename, os.W_OK): - raise GrampsDbWriteFailure( + raise DbWriteFailure( _('Failure writing %s') % filename, _("The database cannot be saved because you do " "not have permission to write to the file. " @@ -150,7 +150,7 @@ class GrampsDbXmlWriter(UpdateCallback): g = open(filename,"w") except IOError,msg: print str(msg) - raise GrampsDbWriteFailure((_('Failure writing %s') % filename, + raise DbWriteFailure((_('Failure writing %s') % filename, str(msg))) return 0 @@ -1189,13 +1189,13 @@ def export_data(database, filename, option_box=None, callback=None): # XmlWriter # #------------------------------------------------------------------------- -class XmlWriter(GrampsDbXmlWriter): +class XmlWriter(GrampsXmlWriter): """ Writes a database to the XML file. """ def __init__(self, dbase, callback, strip_photos, compress=1): - GrampsDbXmlWriter.__init__( + GrampsXmlWriter.__init__( self, dbase, strip_photos, compress, const.VERSION, callback) def write(self, filename): @@ -1204,8 +1204,8 @@ class XmlWriter(GrampsDbXmlWriter): """ ret = 0 #False try: - ret = GrampsDbXmlWriter.write(self, filename) - except GrampsDbWriteFailure, msg: + ret = GrampsXmlWriter.write(self, filename) + except DbWriteFailure, msg: (m1,m2) = msg.messages() ErrorDialog(m1, m2) return ret diff --git a/src/plugins/import/ImportGrdb.py b/src/plugins/import/ImportGrdb.py index 90e3b85f5..de9f5e9e5 100644 --- a/src/plugins/import/ImportGrdb.py +++ b/src/plugins/import/ImportGrdb.py @@ -38,7 +38,7 @@ import cPickle as pickle import time from bsddb import dbshelve, db import logging -__LOG = logging.getLogger(".GrampsDb") +__LOG = logging.getLogger(".Db") #------------------------------------------------------------------------- # @@ -48,12 +48,12 @@ __LOG = logging.getLogger(".GrampsDb") from gen.lib import (GenderStats, Source, Person, Family, Event, Place, MediaObject, Repository, Note, Attribute, AttributeType, NoteType) -from gen.db.write import (GrampsDBDir, KEY_TO_CLASS_MAP, CLASS_TO_KEY_MAP) -from libgrdb import GrampsDbGrdb -from gen.db.txn import GrampsDbTxn as Transaction +from gen.db.write import (DbBsddb, KEY_TO_CLASS_MAP, CLASS_TO_KEY_MAP) +from libgrdb import DbGrdb +from gen.db.txn import DbTxn as Transaction from gen.db.cursor import GrampsCursor from gen.db.dbconst import * -from gen.db.exceptions import GrampsDbVersionError +from gen.db.exceptions import DbVersionError import const from QuestionDialog import ErrorDialog from Errors import HandleError @@ -133,7 +133,7 @@ class GrampsBSDDBDupCursor(GrampsBSDDBAssocCursor): # GrampsBSDDB # #------------------------------------------------------------------------- -class GrampsBSDDB(GrampsDbGrdb, UpdateCallback): +class GrampsBSDDB(DbGrdb, UpdateCallback): """ GRAMPS database object for Berkeley DB. This is replaced for internal use by gen/db/dbdir.py However, this class is still used for import of the 2.2.x @@ -143,7 +143,7 @@ class GrampsBSDDB(GrampsDbGrdb, UpdateCallback): def __init__(self, use_txn = True): """creates a new GrampsDB""" - GrampsDbGrdb.__init__(self) + DbGrdb.__init__(self) #UpdateCallback.__init__(self) self.txn = None self.secondary_connected = False @@ -304,7 +304,7 @@ class GrampsBSDDB(GrampsDbGrdb, UpdateCallback): def get_reference_map_referenced_cursor(self): return GrampsBSDDBDupCursor(self.reference_map_referenced_map, self.txn) - # These are overriding the GrampsDbBase's methods of saving metadata + # These are overriding the DbBase's methods of saving metadata # because we now have txn-capable metadata table def set_default_person_handle(self, handle): """sets the default Person to the passed instance""" @@ -1119,7 +1119,7 @@ class GrampsBSDDB(GrampsDbGrdb, UpdateCallback): self.metadata = None self.env = None self.db_is_open = False - raise GrampsDbVersionError() + raise DbVersionError() def close(self): if not self.db_is_open: @@ -1475,7 +1475,7 @@ class GrampsBSDDB(GrampsDbGrdb, UpdateCallback): else: self.txn = None - GrampsDbBase.transaction_commit(self, transaction, msg) + DbBase.transaction_commit(self, transaction, msg) for (key, data) in transaction.reference_add: self.reference_map.put(str(key), data, txn=self.txn) @@ -1524,7 +1524,7 @@ class GrampsBSDDB(GrampsDbGrdb, UpdateCallback): print "Undoing it" if self.UseTXN: self.txn = self.env.txn_begin() - status = GrampsDbBase.undo(self, update_history) + status = DbBase.undo(self, update_history) if self.UseTXN: if status: self.txn.commit() @@ -1537,7 +1537,7 @@ class GrampsBSDDB(GrampsDbGrdb, UpdateCallback): print "Redoing it" if self.UseTXN: self.txn = self.env.txn_begin() - status = GrampsDbBase.redo(self, update_history) + status = DbBase.redo(self, update_history) if self.UseTXN: if status: self.txn.commit() diff --git a/src/plugins/import/ImportXml.py b/src/plugins/import/ImportXml.py index aa1055058..eb60a836a 100644 --- a/src/plugins/import/ImportXml.py +++ b/src/plugins/import/ImportXml.py @@ -48,7 +48,7 @@ from gen.db.dbconst import (PERSON_KEY, FAMILY_KEY, SOURCE_KEY, EVENT_KEY, from BasicUtils import UpdateCallback import const import libgrampsxml -from libmixin import GrampsDbMixin +from libmixin import DbMixin #------------------------------------------------------------------------- # @@ -83,8 +83,8 @@ EVENT_PERSON_STR = _("%(event_name)s of %(person)s") #------------------------------------------------------------------------- def importData(database, filename, callback=None, cl=0): - if GrampsDbMixin not in database.__class__.__bases__: - database.__class__.__bases__ = (GrampsDbMixin,) + \ + if DbMixin not in database.__class__.__bases__: + database.__class__.__bases__ = (DbMixin,) + \ database.__class__.__bases__ filename = os.path.normpath(filename) diff --git a/src/plugins/lib/libgrdb.py b/src/plugins/lib/libgrdb.py index 0b2e0c541..52cd34214 100644 --- a/src/plugins/lib/libgrdb.py +++ b/src/plugins/lib/libgrdb.py @@ -40,7 +40,7 @@ from bsddb import db from gettext import gettext as _ import logging -LOG = logging.getLogger(".GrampsDb") +LOG = logging.getLogger(".Db") #------------------------------------------------------------------------- # @@ -94,7 +94,7 @@ KEY_TO_CLASS_MAP = {PERSON_KEY: Person.__name__, _SIGBASE = ('person', 'family', 'source', 'event', 'media', 'place', 'repository', 'reference', 'note') -class GrampsDbBookmarks(object): +class DbBookmarks(object): def __init__(self, default=[]): self.bookmarks = list(default) # want a copy (not an alias) @@ -119,7 +119,7 @@ class GrampsDbBookmarks(object): def insert(self, pos, item): self.bookmarks.insert(pos, item) -class GrampsDbGrdb(Callback): +class DbGrdb(Callback): """ GRAMPS database object. This object is a base class for all database interfaces. @@ -177,7 +177,7 @@ class GrampsDbGrdb(Callback): def __init__(self): """ - Create a new GrampsDbBase instance. + Create a new DbBase instance. A new GrampDbBase class should never be directly created. Only classes derived from this class should be created. @@ -256,14 +256,14 @@ class GrampsDbGrdb(Callback): self.default = None self.owner = Researcher() self.name_formats = [] - self.bookmarks = GrampsDbBookmarks() - self.family_bookmarks = GrampsDbBookmarks() - self.event_bookmarks = GrampsDbBookmarks() - self.place_bookmarks = GrampsDbBookmarks() - self.source_bookmarks = GrampsDbBookmarks() - self.repo_bookmarks = GrampsDbBookmarks() - self.media_bookmarks = GrampsDbBookmarks() - self.note_bookmarks = GrampsDbBookmarks() + self.bookmarks = DbBookmarks() + self.family_bookmarks = DbBookmarks() + self.event_bookmarks = DbBookmarks() + self.place_bookmarks = DbBookmarks() + self.source_bookmarks = DbBookmarks() + self.repo_bookmarks = DbBookmarks() + self.media_bookmarks = DbBookmarks() + self.note_bookmarks = DbBookmarks() self._bm_changes = 0 self.path = "" self.surname_list = [] @@ -2600,7 +2600,7 @@ class Transaction(object): Create a new transaction. A Transaction instance should not be created directly, but by the - GrampsDbBase class or classes derived from GrampsDbBase. The db + DbBase class or classes derived from DbBase. The db parameter is a list-like interface that stores the commit data. This could be a simple list, or a RECNO-style database object. diff --git a/src/plugins/lib/libmixin.py b/src/plugins/lib/libmixin.py index 850c3b055..bbcde470a 100644 --- a/src/plugins/lib/libmixin.py +++ b/src/plugins/lib/libmixin.py @@ -21,7 +21,7 @@ # $Id$ """ -Mixin for GrampsDbDir to enable find_from_handle and check_from_handle methods. +Mixin for DbDir to enable find_from_handle and check_from_handle methods. """ #------------------------------------------------------------------------------ @@ -34,17 +34,17 @@ from gen.lib import (GenderStats, Person, Family, Event, Place, Source, #------------------------------------------------------------------------------ # -# GrampsDbMixin class +# DbMixin class # #------------------------------------------------------------------------------ -class GrampsDbMixin(object): +class DbMixin(object): """ - GrampsDbMixin -- a collection of methods to be added to the main + DbMixin -- a collection of methods to be added to the main gramps database class for use with import functions. To enable these functions, add the following code to your module: - if GrampsDbMixin not in database.__class__.__bases__: - database.__class__.__bases__ = (GrampsDbMixin,) + \ + if DbMixin not in database.__class__.__bases__: + database.__class__.__bases__ = (DbMixin,) + \ database.__class__.__bases__ where "database" is the object name of your instance of the gramps diff --git a/src/plugins/lib/libnarrate.py b/src/plugins/lib/libnarrate.py index e404acf37..1ed51d4bf 100644 --- a/src/plugins/lib/libnarrate.py +++ b/src/plugins/lib/libnarrate.py @@ -1460,7 +1460,7 @@ class Narrator(object): Initialize the narrator class. :param dbase: The database that contains the data to be narrated. - :type dbase: :class:`~gen.db.base,GrampsDbBase` + :type dbase: :class:`~gen.db.base,DbBase` :param verbose: Specifies whether complete sentences should be used. :type verbose: bool :param use_call_name: Specifies whether a person's call name should be diff --git a/src/plugins/tool/Check.py b/src/plugins/tool/Check.py index d27194fda..5714bb5e7 100644 --- a/src/plugins/tool/Check.py +++ b/src/plugins/tool/Check.py @@ -113,8 +113,8 @@ def _table_low_level(db,table): return True # import gen.db - from gen.db import GrampsDBDirAssocCursor - table_cursor = GrampsDBDirAssocCursor(table) + from gen.db import DbBsddbAssocCursor + table_cursor = DbBsddbAssocCursor(table) for handle in dup_handles: print " Duplicates found for handle: %s" % handle try: @@ -163,7 +163,7 @@ class Check(Tool.BatchTool): # The low-level repair is bypassing the transaction mechanism. # As such, we run it before starting the transaction. # We only do this for the dbdir backend. - if self.db.__class__.__name__ == 'GrampsDBDir': + if self.db.__class__.__name__ == 'DbBsddb': low_level(self.db) trans = self.db.transaction_begin("", batch=True) diff --git a/src/web/djangodb.py b/src/web/djangodb.py index 9eaffa7af..e155e563f 100644 --- a/src/web/djangodb.py +++ b/src/web/djangodb.py @@ -19,7 +19,7 @@ # $Id$ # -""" Implements a GrampsDb interface """ +""" Implements a Db interface """ #------------------------------------------------------------------------ # @@ -28,7 +28,7 @@ #------------------------------------------------------------------------ import web import gen -from gen.db import GrampsDbBase +from gen.db import DbBase from web.libdjango import DjangoInterface # from ReportBase._CommandLineReport import run_report @@ -50,7 +50,7 @@ class Cursor(object): def __exit__(self, *args, **kwargs): pass -class DjangoDb(GrampsDbBase): +class DjangoDb(DbBase): """ A Gramps Database Backend. This replicates the grampsdb functions. """