2007-06-03 Don Allingham <don@gramps-project.org>
* src/Simple/__init__.py: add svn: r8531
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
2007-06-03 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/Simple/__init__.py: add
|
||||||
|
|
||||||
2007-06-01 Alex Roitman <shura@gramps-project.org>
|
2007-06-01 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/DbLoader.py (_OPEN_FORMATS): Remove grdb from the native
|
* src/DbLoader.py (_OPEN_FORMATS): Remove grdb from the native
|
||||||
format list.
|
format list.
|
||||||
|
300
INSTALL
300
INSTALL
@@ -1,98 +1,236 @@
|
|||||||
$Id$
|
Installation Instructions
|
||||||
|
*************************
|
||||||
|
|
||||||
This file contains some useful details on the installation from source code
|
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
|
||||||
for GRAMPS. It does not cover installation of a pre-built binary package.
|
Software Foundation, Inc.
|
||||||
For that use your package manager, the rest is already done by the packager.
|
|
||||||
|
|
||||||
|
This file is free documentation; the Free Software Foundation gives
|
||||||
|
unlimited permission to copy, distribute and modify it.
|
||||||
|
|
||||||
configure vs autogen scripts
|
Basic Installation
|
||||||
----------------------------
|
==================
|
||||||
If you are building from released tarball, you should be able to just
|
|
||||||
run "./configure && make". However, if you're building from the SVN,
|
|
||||||
the configure is not present. You should auto-generate it by
|
|
||||||
running ./autogen.sh and then "make" and, finally, "make install".
|
|
||||||
|
|
||||||
Running ./autogen.sh on this branch of gramps requires the following
|
These are generic installation instructions.
|
||||||
packages to be installed:
|
|
||||||
* automake-1.9
|
|
||||||
* gnome-common
|
|
||||||
* intltool
|
|
||||||
* libglib2.0-dev (may be called differently on other distros) and
|
|
||||||
maybe something else. If autogen.sh fails, it should inform you what's
|
|
||||||
missing.
|
|
||||||
|
|
||||||
|
The `configure' shell script attempts to guess correct values for
|
||||||
|
various system-dependent variables used during compilation. It uses
|
||||||
|
those values to create a `Makefile' in each directory of the package.
|
||||||
|
It may also create one or more `.h' files containing system-dependent
|
||||||
|
definitions. Finally, it creates a shell script `config.status' that
|
||||||
|
you can run in the future to recreate the current configuration, and a
|
||||||
|
file `config.log' containing compiler output (useful mainly for
|
||||||
|
debugging `configure').
|
||||||
|
|
||||||
Regular vs local installation
|
It can also use an optional file (typically called `config.cache'
|
||||||
-----------------------------
|
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||||
This version of gramps requires, among others, the two things to be done:
|
the results of its tests to speed up reconfiguring. (Caching is
|
||||||
gconf schemas and mime types for gramps MUST be properly installed.
|
disabled by default to prevent problems with accidental use of stale
|
||||||
The usual ./configure, make, and make install as a root should do the trick.
|
cache files.)
|
||||||
But be careful if you're using the non-default options or would like
|
|
||||||
to install without being root.
|
|
||||||
|
|
||||||
The latter is possible, but you should supply additional arguments to
|
If you need to do unusual things to compile the package, please try
|
||||||
autogen or configure:
|
to figure out how `configure' could check whether to do them, and mail
|
||||||
--with-gconf-source=xml::$HOME/.gconf
|
diffs or instructions to the address given in the `README' so they can
|
||||||
--with-gconf-schema-file-dir=$HOME
|
be considered for the next release. If you are using the cache, and at
|
||||||
--with-mime-dir=$HOME/.local/share/mime
|
some point `config.cache' contains results you don't want to keep, you
|
||||||
--disable-scrollkeeper
|
may remove or edit it.
|
||||||
Most likely, such local install will also need some prefix with write
|
|
||||||
permissions for you:
|
|
||||||
--prefix=$HOME/my_gramps_path
|
|
||||||
|
|
||||||
Whether you're doing local install or regular install,
|
The file `configure.ac' (or `configure.in') is used to create
|
||||||
YOU MUST INSTALL GCONF SCHEMAS AND MIME TYPES.
|
`configure' by a program called `autoconf'. You only need
|
||||||
YOU HAVE BEEN WARNED!
|
`configure.ac' if you want to change it or regenerate `configure' using
|
||||||
|
a newer version of `autoconf'.
|
||||||
|
|
||||||
|
The simplest way to compile this package is:
|
||||||
|
|
||||||
Installing under non-default prefix
|
1. `cd' to the directory containing the package's source code and type
|
||||||
-----------------------------------
|
`./configure' to configure the package for your system. If you're
|
||||||
As hinted above, the gconf schemas and mime types for gramps
|
using `csh' on an old version of System V, you might need to type
|
||||||
MUST be properly installed. The "proper install" means installing
|
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||||
them where gconfd and shared mime system, respectively, will
|
`configure' itself.
|
||||||
find them.
|
|
||||||
|
|
||||||
By default, gconfd will look in these places:
|
Running `configure' takes awhile. While running, it prints some
|
||||||
1. Whatever is returned by running:
|
messages telling which features it is checking for.
|
||||||
$ gconftool-2 --get-default-source
|
|
||||||
2. The xml::$HOME/.gconf : this is a per-user setup, not system-wide
|
|
||||||
or xml:merged:$HOME/.gconf : this is a per-user setup, not system-wide
|
|
||||||
There is a number of ways to let gconfd know where else
|
|
||||||
to look, but this is outside the scope of installing gramps.
|
|
||||||
|
|
||||||
By default, the shared mime systems will look in these places:
|
2. Type `make' to compile the package.
|
||||||
1. /usr/share/mime
|
|
||||||
2. /usr/local/share/mime : this may be broken on some systems
|
|
||||||
3. $HOME/.local/share/mime : this is a per-user setup, not system-wide
|
|
||||||
Likewise, there's a number of ways to instruct the shared mime system
|
|
||||||
to look in other places, but this is the whole other story.
|
|
||||||
|
|
||||||
So if you install some place other than /usr/share, you will most
|
3. Optionally, type `make check' to run any self-tests that come with
|
||||||
likely need to add this option to autogen.sh/configure scripts:
|
the package.
|
||||||
--with-mime-dir=/usr/share/mime
|
|
||||||
|
|
||||||
Using the --prefix=/usr/share and installing as a root will most
|
4. Type `make install' to install the programs and any data files and
|
||||||
likely do everything correctly, so no extra care needs to be
|
documentation.
|
||||||
taken. You should take extra care only if you are installing under
|
|
||||||
something like --prefix=/usr/local/my_gramps, /var/gramps123/blah, etc.
|
|
||||||
|
|
||||||
|
5. You can remove the program binaries and object files from the
|
||||||
|
source code directory by typing `make clean'. To also remove the
|
||||||
|
files that `configure' created (so you can compile the package for
|
||||||
|
a different kind of computer), type `make distclean'. There is
|
||||||
|
also a `make maintainer-clean' target, but that is intended mainly
|
||||||
|
for the package's developers. If you use it, you may have to get
|
||||||
|
all sorts of other programs in order to regenerate files that came
|
||||||
|
with the distribution.
|
||||||
|
|
||||||
Packager's issues
|
Compilers and Options
|
||||||
------------------
|
=====================
|
||||||
The above mentioned gconf schemas and mime types must be installed.
|
|
||||||
However, the update-mime-database and the gconftool-2 calls to process
|
Some systems require unusual options for compilation or linking that the
|
||||||
the newly installed types and schemas must be done in POST-INSTALLATION.
|
`configure' script does not know about. Run `./configure --help' for
|
||||||
In packager's world, the install happens on packager's machine
|
details on some of the pertinent environment variables.
|
||||||
into something like /tmp/gramps-tmp. However, the postinstall
|
|
||||||
should happen on the user's machine.
|
You can give `configure' initial values for configuration parameters
|
||||||
|
by setting variables in the command line or in the environment. Here
|
||||||
|
is an example:
|
||||||
|
|
||||||
|
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||||
|
|
||||||
|
*Note Defining Variables::, for more details.
|
||||||
|
|
||||||
|
Compiling For Multiple Architectures
|
||||||
|
====================================
|
||||||
|
|
||||||
|
You can compile the package for more than one kind of computer at the
|
||||||
|
same time, by placing the object files for each architecture in their
|
||||||
|
own directory. To do this, you must use a version of `make' that
|
||||||
|
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||||
|
directory where you want the object files and executables to go and run
|
||||||
|
the `configure' script. `configure' automatically checks for the
|
||||||
|
source code in the directory that `configure' is in and in `..'.
|
||||||
|
|
||||||
|
If you have to use a `make' that does not support the `VPATH'
|
||||||
|
variable, you have to compile the package for one architecture at a
|
||||||
|
time in the source code directory. After you have installed the
|
||||||
|
package for one architecture, use `make distclean' before reconfiguring
|
||||||
|
for another architecture.
|
||||||
|
|
||||||
|
Installation Names
|
||||||
|
==================
|
||||||
|
|
||||||
|
By default, `make install' installs the package's commands under
|
||||||
|
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||||
|
can specify an installation prefix other than `/usr/local' by giving
|
||||||
|
`configure' the option `--prefix=PREFIX'.
|
||||||
|
|
||||||
|
You can specify separate installation prefixes for
|
||||||
|
architecture-specific files and architecture-independent files. If you
|
||||||
|
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||||
|
PREFIX as the prefix for installing programs and libraries.
|
||||||
|
Documentation and other data files still use the regular prefix.
|
||||||
|
|
||||||
|
In addition, if you use an unusual directory layout you can give
|
||||||
|
options like `--bindir=DIR' to specify different values for particular
|
||||||
|
kinds of files. Run `configure --help' for a list of the directories
|
||||||
|
you can set and what kinds of files go in them.
|
||||||
|
|
||||||
|
If the package supports it, you can cause programs to be installed
|
||||||
|
with an extra prefix or suffix on their names by giving `configure' the
|
||||||
|
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||||
|
|
||||||
|
Optional Features
|
||||||
|
=================
|
||||||
|
|
||||||
|
Some packages pay attention to `--enable-FEATURE' options to
|
||||||
|
`configure', where FEATURE indicates an optional part of the package.
|
||||||
|
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||||
|
is something like `gnu-as' or `x' (for the X Window System). The
|
||||||
|
`README' should mention any `--enable-' and `--with-' options that the
|
||||||
|
package recognizes.
|
||||||
|
|
||||||
|
For packages that use the X Window System, `configure' can usually
|
||||||
|
find the X include and library files automatically, but if it doesn't,
|
||||||
|
you can use the `configure' options `--x-includes=DIR' and
|
||||||
|
`--x-libraries=DIR' to specify their locations.
|
||||||
|
|
||||||
|
Specifying the System Type
|
||||||
|
==========================
|
||||||
|
|
||||||
|
There may be some features `configure' cannot figure out automatically,
|
||||||
|
but needs to determine by the type of machine the package will run on.
|
||||||
|
Usually, assuming the package is built to be run on the _same_
|
||||||
|
architectures, `configure' can figure that out, but if it prints a
|
||||||
|
message saying it cannot guess the machine type, give it the
|
||||||
|
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||||
|
type, such as `sun4', or a canonical name which has the form:
|
||||||
|
|
||||||
|
CPU-COMPANY-SYSTEM
|
||||||
|
|
||||||
|
where SYSTEM can have one of these forms:
|
||||||
|
|
||||||
|
OS KERNEL-OS
|
||||||
|
|
||||||
|
See the file `config.sub' for the possible values of each field. If
|
||||||
|
`config.sub' isn't included in this package, then this package doesn't
|
||||||
|
need to know the machine type.
|
||||||
|
|
||||||
|
If you are _building_ compiler tools for cross-compiling, you should
|
||||||
|
use the option `--target=TYPE' to select the type of system they will
|
||||||
|
produce code for.
|
||||||
|
|
||||||
|
If you want to _use_ a cross compiler, that generates code for a
|
||||||
|
platform different from the build platform, you should specify the
|
||||||
|
"host" platform (i.e., that on which the generated programs will
|
||||||
|
eventually be run) with `--host=TYPE'.
|
||||||
|
|
||||||
|
Sharing Defaults
|
||||||
|
================
|
||||||
|
|
||||||
|
If you want to set default values for `configure' scripts to share, you
|
||||||
|
can create a site shell script called `config.site' that gives default
|
||||||
|
values for variables like `CC', `cache_file', and `prefix'.
|
||||||
|
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||||
|
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||||
|
`CONFIG_SITE' environment variable to the location of the site script.
|
||||||
|
A warning: not all `configure' scripts look for a site script.
|
||||||
|
|
||||||
|
Defining Variables
|
||||||
|
==================
|
||||||
|
|
||||||
|
Variables not defined in a site shell script can be set in the
|
||||||
|
environment passed to `configure'. However, some packages may run
|
||||||
|
configure again during the build, and the customized values of these
|
||||||
|
variables may be lost. In order to avoid this problem, you should set
|
||||||
|
them in the `configure' command line, using `VAR=value'. For example:
|
||||||
|
|
||||||
|
./configure CC=/usr/local2/bin/gcc
|
||||||
|
|
||||||
|
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||||
|
overridden in the site shell script). Here is a another example:
|
||||||
|
|
||||||
|
/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||||
|
|
||||||
|
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
|
||||||
|
configuration-related scripts to be executed by `/bin/bash'.
|
||||||
|
|
||||||
|
`configure' Invocation
|
||||||
|
======================
|
||||||
|
|
||||||
|
`configure' recognizes the following options to control how it operates.
|
||||||
|
|
||||||
|
`--help'
|
||||||
|
`-h'
|
||||||
|
Print a summary of the options to `configure', and exit.
|
||||||
|
|
||||||
|
`--version'
|
||||||
|
`-V'
|
||||||
|
Print the version of Autoconf used to generate the `configure'
|
||||||
|
script, and exit.
|
||||||
|
|
||||||
|
`--cache-file=FILE'
|
||||||
|
Enable the cache: use and save the results of the tests in FILE,
|
||||||
|
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||||
|
disable caching.
|
||||||
|
|
||||||
|
`--config-cache'
|
||||||
|
`-C'
|
||||||
|
Alias for `--cache-file=config.cache'.
|
||||||
|
|
||||||
|
`--quiet'
|
||||||
|
`--silent'
|
||||||
|
`-q'
|
||||||
|
Do not print messages saying which checks are being made. To
|
||||||
|
suppress all normal output, redirect it to `/dev/null' (any error
|
||||||
|
messages will still be shown).
|
||||||
|
|
||||||
|
`--srcdir=DIR'
|
||||||
|
Look for the package's source code in directory DIR. Usually
|
||||||
|
`configure' can determine that directory automatically.
|
||||||
|
|
||||||
|
`configure' also accepts some other, not widely useful, options. Run
|
||||||
|
`configure --help' for more details.
|
||||||
|
|
||||||
To assist with that, there's an argument available in configure
|
|
||||||
(or autogen, which will pass it to configure) which disables
|
|
||||||
the gconf schema and mime type processing:
|
|
||||||
--enable-packager-mode
|
|
||||||
This argument should disable postinstall calls made during
|
|
||||||
make install, and print a nasty warning during configure.
|
|
||||||
IT IS PACKAGER'S RESPONSIBILITY to follow the advice given
|
|
||||||
by the configure output and to copy the appropriate code
|
|
||||||
from the src/data/Makefile.am into the post-install (and post-uninstall)
|
|
||||||
of the particular packaging system.
|
|
||||||
|
@@ -29,6 +29,15 @@ MOSTLYCLEANFILES = *pyc *pyo
|
|||||||
|
|
||||||
GRAMPS_PY_MODPATH = ".."
|
GRAMPS_PY_MODPATH = ".."
|
||||||
|
|
||||||
|
docfiles=\
|
||||||
|
_DateDisplay.py\
|
||||||
|
_DateParser.py\
|
||||||
|
_DateHandler.py\
|
||||||
|
_DateUtils.py
|
||||||
|
|
||||||
|
docs:
|
||||||
|
export PYTHONPATH='..'; epydoc --graph=umlclasstree -o ../html --url http://gramps-project.org --name GRAMPS --html $(docfiles)
|
||||||
|
|
||||||
pycheck:
|
pycheck:
|
||||||
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
||||||
pychecker $(pkgdata_PYTHON));
|
pychecker $(pkgdata_PYTHON));
|
||||||
|
@@ -75,7 +75,7 @@ _KNOWN_FORMATS = {
|
|||||||
const.app_gedcom : _('GEDCOM'),
|
const.app_gedcom : _('GEDCOM'),
|
||||||
}
|
}
|
||||||
|
|
||||||
_OPEN_FORMATS = [const.app_gramps_xml, const.app_gedcom]
|
OPEN_FORMATS = [const.app_gramps_xml, const.app_gedcom]
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -101,7 +101,7 @@ class DbLoader:
|
|||||||
add_xml_filter(choose)
|
add_xml_filter(choose)
|
||||||
add_gedcom_filter(choose)
|
add_gedcom_filter(choose)
|
||||||
|
|
||||||
(box, type_selector) = format_maker(_OPEN_FORMATS)
|
(box, type_selector) = format_maker(OPEN_FORMATS)
|
||||||
choose.set_extra_widget(box)
|
choose.set_extra_widget(box)
|
||||||
|
|
||||||
choose.set_current_folder(get_default_dir())
|
choose.set_current_folder(get_default_dir())
|
||||||
@@ -117,7 +117,7 @@ class DbLoader:
|
|||||||
filetype = Mime.get_type(filename)
|
filetype = Mime.get_type(filename)
|
||||||
(the_path, the_file) = os.path.split(filename)
|
(the_path, the_file) = os.path.split(filename)
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
if filetype in _OPEN_FORMATS:
|
if filetype in OPEN_FORMATS:
|
||||||
self.read_file(filename, filetype)
|
self.read_file(filename, filetype)
|
||||||
try:
|
try:
|
||||||
os.chdir(os.path.dirname(filename))
|
os.chdir(os.path.dirname(filename))
|
||||||
@@ -213,7 +213,7 @@ class DbLoader:
|
|||||||
add_xml_filter(choose)
|
add_xml_filter(choose)
|
||||||
add_gedcom_filter(choose)
|
add_gedcom_filter(choose)
|
||||||
|
|
||||||
(box, type_selector) = format_maker(_OPEN_FORMATS)
|
(box, type_selector) = format_maker(OPEN_FORMATS)
|
||||||
choose.set_extra_widget(box)
|
choose.set_extra_widget(box)
|
||||||
|
|
||||||
default_dir = get_default_dir()
|
default_dir = get_default_dir()
|
||||||
@@ -246,7 +246,7 @@ class DbLoader:
|
|||||||
str(msg))
|
str(msg))
|
||||||
return ('','')
|
return ('','')
|
||||||
# First we try our best formats
|
# First we try our best formats
|
||||||
if filetype not in _OPEN_FORMATS:
|
if filetype not in OPEN_FORMATS:
|
||||||
QuestionDialog.ErrorDialog(
|
QuestionDialog.ErrorDialog(
|
||||||
_("Could not open file: %s") % filename,
|
_("Could not open file: %s") % filename,
|
||||||
_("Unknown type: %s") % filetype
|
_("Unknown type: %s") % filetype
|
||||||
@@ -290,7 +290,7 @@ class DbLoader:
|
|||||||
add_xml_filter(choose)
|
add_xml_filter(choose)
|
||||||
add_gedcom_filter(choose)
|
add_gedcom_filter(choose)
|
||||||
|
|
||||||
format_list = _OPEN_FORMATS[:]
|
format_list = OPEN_FORMATS
|
||||||
|
|
||||||
# Add more data type selections if opening existing db
|
# Add more data type selections if opening existing db
|
||||||
for data in import_list:
|
for data in import_list:
|
||||||
@@ -336,7 +336,7 @@ class DbLoader:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# First we try our best formats
|
# First we try our best formats
|
||||||
if filetype in _OPEN_FORMATS:
|
if filetype in OPEN_FORMATS:
|
||||||
importer = GrampsDbUtils.gramps_db_reader_factory(filetype)
|
importer = GrampsDbUtils.gramps_db_reader_factory(filetype)
|
||||||
self.do_import(choose, importer, filename)
|
self.do_import(choose, importer, filename)
|
||||||
return True
|
return True
|
||||||
@@ -549,7 +549,7 @@ def add_gramps_files_filter(chooser):
|
|||||||
"""
|
"""
|
||||||
mime_filter = gtk.FileFilter()
|
mime_filter = gtk.FileFilter()
|
||||||
mime_filter.set_name(_('All GRAMPS files'))
|
mime_filter.set_name(_('All GRAMPS files'))
|
||||||
for fmt in _OPEN_FORMATS:
|
for fmt in OPEN_FORMATS:
|
||||||
mime_filter.add_mime_type(fmt)
|
mime_filter.add_mime_type(fmt)
|
||||||
chooser.add_filter(mime_filter)
|
chooser.add_filter(mime_filter)
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@ pkgdata_PYTHON = \
|
|||||||
_DbUtils.py \
|
_DbUtils.py \
|
||||||
_GrampsBSDDB.py\
|
_GrampsBSDDB.py\
|
||||||
_GrampsDbBase.py\
|
_GrampsDbBase.py\
|
||||||
|
_GrampsCursor.py\
|
||||||
_GrampsDBCallback.py\
|
_GrampsDBCallback.py\
|
||||||
_GrampsDbExceptions.py\
|
_GrampsDbExceptions.py\
|
||||||
_GrampsDbFactories.py\
|
_GrampsDbFactories.py\
|
||||||
|
@@ -37,7 +37,7 @@ import time
|
|||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from bsddb import dbshelve, db
|
from bsddb import dbshelve, db
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(".GrampsDb")
|
__LOG = logging.getLogger(".GrampsDb")
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -51,28 +51,53 @@ import _GrampsDbConst as const
|
|||||||
from _GrampsDbExceptions import FileVersionError
|
from _GrampsDbExceptions import FileVersionError
|
||||||
from BasicUtils import UpdateCallback
|
from BasicUtils import UpdateCallback
|
||||||
|
|
||||||
|
from _GrampsCursor import GrampsCursor
|
||||||
|
|
||||||
_MINVERSION = 9
|
_MINVERSION = 9
|
||||||
_DBVERSION = 13
|
_DBVERSION = 13
|
||||||
|
|
||||||
def find_surname(key,data):
|
#--------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Secondary index functions
|
||||||
|
#
|
||||||
|
#--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def __find_surname(key, data):
|
||||||
|
"""
|
||||||
|
Returns the surname from the data stream. Used for building a secondary
|
||||||
|
index.
|
||||||
|
"""
|
||||||
return str(data[3][5])
|
return str(data[3][5])
|
||||||
|
|
||||||
def find_idmap(key,data):
|
def __find_idmap(key, data):
|
||||||
|
"""
|
||||||
|
Returns the ID from the data stream. Used for building a secondary
|
||||||
|
index.
|
||||||
|
"""
|
||||||
return str(data[1])
|
return str(data[1])
|
||||||
|
|
||||||
# Secondary database key lookups for reference_map table
|
def __find_primary_handle(key, data):
|
||||||
# reference_map data values are of the form:
|
"""
|
||||||
# ((primary_object_class_name, primary_object_handle),
|
Secondary database key lookups for reference_map table
|
||||||
# (referenced_object_class_name, referenced_object_handle))
|
reference_map data values are of the form:
|
||||||
|
((primary_object_class_name, primary_object_handle),
|
||||||
def find_primary_handle(key,data):
|
(referenced_object_class_name, referenced_object_handle))
|
||||||
|
"""
|
||||||
return str((data)[0][1])
|
return str((data)[0][1])
|
||||||
|
|
||||||
def find_referenced_handle(key,data):
|
def __find_referenced_handle(key, data):
|
||||||
|
"""
|
||||||
|
Secondary database key lookups for reference_map table
|
||||||
|
reference_map data values are of the form:
|
||||||
|
((primary_object_class_name, primary_object_handle),
|
||||||
|
(referenced_object_class_name, referenced_object_handle))
|
||||||
|
"""
|
||||||
return str((data)[1][1])
|
return str((data)[1][1])
|
||||||
|
|
||||||
class GrampsBSDDBCursor(GrampsCursor):
|
class GrampsBSDDBCursor(GrampsCursor):
|
||||||
|
"""
|
||||||
|
Cursor to loop through a BSDDB table
|
||||||
|
"""
|
||||||
def __init__(self, source, txn=None):
|
def __init__(self, source, txn=None):
|
||||||
self.cursor = source.db.cursor(txn)
|
self.cursor = source.db.cursor(txn)
|
||||||
self.source = source
|
self.source = source
|
||||||
@@ -134,7 +159,6 @@ class GrampsBSDDBDupCursor(GrampsBSDDBAssocCursor):
|
|||||||
def next_dup(self):
|
def next_dup(self):
|
||||||
return self.cursor.next_dup()
|
return self.cursor.next_dup()
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GrampsBSDDB
|
# GrampsBSDDB
|
||||||
@@ -148,27 +172,28 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
"""creates a new GrampsDB"""
|
"""creates a new GrampsDB"""
|
||||||
|
|
||||||
GrampsDbBase.__init__(self)
|
GrampsDbBase.__init__(self)
|
||||||
|
#xUpdateCallback.__init__(self)
|
||||||
self.txn = None
|
self.txn = None
|
||||||
self.secondary_connected = False
|
self.secondary_connected = False
|
||||||
self.UseTXN = use_txn
|
self.UseTXN = use_txn
|
||||||
|
|
||||||
def open_flags(self):
|
def __open_flags(self):
|
||||||
if self.UseTXN:
|
if self.UseTXN:
|
||||||
return db.DB_CREATE|db.DB_AUTO_COMMIT
|
return db.DB_CREATE|db.DB_AUTO_COMMIT
|
||||||
else:
|
else:
|
||||||
return db.DB_CREATE
|
return db.DB_CREATE
|
||||||
|
|
||||||
def open_table(self,file_name,table_name,dbtype=db.DB_HASH):
|
def __open_table(self, file_name, table_name, dbtype=db.DB_HASH):
|
||||||
dbmap = dbshelve.DBShelf(self.env)
|
dbmap = dbshelve.DBShelf(self.env)
|
||||||
dbmap.db.set_pagesize(16384)
|
dbmap.db.set_pagesize(16384)
|
||||||
print file_name
|
print file_name
|
||||||
if self.readonly:
|
if self.readonly:
|
||||||
dbmap.open(file_name, table_name, dbtype, db.DB_RDONLY)
|
dbmap.open(file_name, table_name, dbtype, db.DB_RDONLY)
|
||||||
else:
|
else:
|
||||||
dbmap.open(file_name, table_name, dbtype, self.open_flags(), 0666)
|
dbmap.open(file_name, table_name, dbtype, self.__open_flags(), 0666)
|
||||||
return dbmap
|
return dbmap
|
||||||
|
|
||||||
def _all_handles(self,table):
|
def __all_handles(self, table):
|
||||||
return table.keys(self.txn)
|
return table.keys(self.txn)
|
||||||
|
|
||||||
def get_person_cursor(self):
|
def get_person_cursor(self):
|
||||||
@@ -244,27 +269,51 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
return self.source_map.get(str(handle), txn=self.txn) != None
|
return self.source_map.get(str(handle), txn=self.txn) != None
|
||||||
|
|
||||||
def get_raw_person_data(self, handle):
|
def get_raw_person_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for a person
|
||||||
|
"""
|
||||||
return self.person_map.get(str(handle), txn=self.txn)
|
return self.person_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
def get_raw_family_data(self, handle):
|
def get_raw_family_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for a family
|
||||||
|
"""
|
||||||
return self.family_map.get(str(handle), txn=self.txn)
|
return self.family_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
def get_raw_object_data(self, handle):
|
def get_raw_object_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for a media object
|
||||||
|
"""
|
||||||
return self.media_map.get(str(handle), txn=self.txn)
|
return self.media_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
def get_raw_place_data(self, handle):
|
def get_raw_place_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for a place
|
||||||
|
"""
|
||||||
return self.place_map.get(str(handle), txn=self.txn)
|
return self.place_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
def get_raw_event_data(self, handle):
|
def get_raw_event_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for an event
|
||||||
|
"""
|
||||||
return self.event_map.get(str(handle), txn=self.txn)
|
return self.event_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
def get_raw_source_data(self, handle):
|
def get_raw_source_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for a source
|
||||||
|
"""
|
||||||
return self.source_map.get(str(handle), txn=self.txn)
|
return self.source_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
def get_raw_repository_data(self, handle):
|
def get_raw_repository_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for a repository
|
||||||
|
"""
|
||||||
return self.repository_map.get(str(handle), txn=self.txn)
|
return self.repository_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
def get_raw_note_data(self, handle):
|
def get_raw_note_data(self, handle):
|
||||||
|
"""
|
||||||
|
returns the raw, unserialized data for a note
|
||||||
|
"""
|
||||||
return self.note_map.get(str(handle), txn=self.txn)
|
return self.note_map.get(str(handle), txn=self.txn)
|
||||||
|
|
||||||
# cursors for lookups in the reference_map for back reference
|
# cursors for lookups in the reference_map for back reference
|
||||||
@@ -371,28 +420,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
# Environment name is now based on the filename
|
# Environment name is now based on the filename
|
||||||
drive, tmp_name = os.path.splitdrive(self.full_name)
|
drive, tmp_name = os.path.splitdrive(self.full_name)
|
||||||
tmp_name = tmp_name.lstrip(os.sep)
|
tmp_name = tmp_name.lstrip(os.sep)
|
||||||
env_name = os.path.join(os.path.expanduser(const.env_dir),
|
env_name = os.path.join(os.path.expanduser(const.env_dir), tmp_name)
|
||||||
tmp_name)
|
|
||||||
|
|
||||||
# Create the env dir if it does not exist
|
|
||||||
if not os.path.isdir(env_name):
|
|
||||||
os.makedirs(env_name)
|
|
||||||
# If this is not a new db, see about copying old env dir
|
|
||||||
if os.path.isfile(self.full_name):
|
|
||||||
common_env_name = os.path.expanduser(const.bsddbenv_dir)
|
|
||||||
# Copy the old env dir contents into the new one
|
|
||||||
# ONLY if the old env dir exists
|
|
||||||
if os.path.isdir(common_env_name):
|
|
||||||
shutil.rmtree(env_name)
|
|
||||||
shutil.copytree(common_env_name,env_name)
|
|
||||||
else:
|
|
||||||
# For existing env and new database, clean the env
|
|
||||||
# (means the env dir remains from previous db
|
|
||||||
# with the same name)
|
|
||||||
if not os.path.isfile(self.full_name):
|
|
||||||
shutil.rmtree(env_name)
|
|
||||||
os.mkdir(env_name)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
env_flags = db.DB_CREATE | db.DB_PRIVATE | db.DB_INIT_MPOOL
|
env_flags = db.DB_CREATE | db.DB_PRIVATE | db.DB_INIT_MPOOL
|
||||||
env_name = os.path.expanduser('~')
|
env_name = os.path.expanduser('~')
|
||||||
@@ -402,26 +430,25 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
self.env.txn_checkpoint()
|
self.env.txn_checkpoint()
|
||||||
|
|
||||||
callback(25)
|
callback(25)
|
||||||
self.metadata = self.open_table(self.full_name,"meta")
|
self.metadata = self.__open_table(self.full_name, "meta")
|
||||||
|
|
||||||
# If we cannot work with this DB version,
|
# If we cannot work with this DB version,
|
||||||
# it makes no sense to go further
|
# it makes no sense to go further
|
||||||
if not self.version_supported:
|
if not self.version_supported:
|
||||||
self._close_early()
|
self.__close_early()
|
||||||
|
|
||||||
self.family_map = self.open_table(self.full_name, "family")
|
self.family_map = self.__open_table(self.full_name, "family")
|
||||||
self.place_map = self.open_table(self.full_name, "places")
|
self.place_map = self.__open_table(self.full_name, "places")
|
||||||
self.source_map = self.open_table(self.full_name, "sources")
|
self.source_map = self.__open_table(self.full_name, "sources")
|
||||||
self.media_map = self.open_table(self.full_name, "media")
|
self.media_map = self.__open_table(self.full_name, "media")
|
||||||
self.event_map = self.open_table(self.full_name, "events")
|
self.event_map = self.__open_table(self.full_name, "events")
|
||||||
self.person_map = self.open_table(self.full_name, "person")
|
self.person_map = self.__open_table(self.full_name, "person")
|
||||||
self.repository_map = self.open_table(self.full_name, "repository")
|
self.repository_map = self.__open_table(self.full_name, "repository")
|
||||||
self.note_map = self.open_table(self.full_name, "note")
|
self.note_map = self.__open_table(self.full_name, "note")
|
||||||
self.reference_map = self.open_table(self.full_name, "reference_map",
|
self.reference_map = self.__open_table(self.full_name, "reference_map",
|
||||||
dbtype=db.DB_BTREE)
|
dbtype=db.DB_BTREE)
|
||||||
callback(37)
|
|
||||||
|
|
||||||
self._load_metadata()
|
self.__load_metadata()
|
||||||
|
|
||||||
gstats = self.metadata.get('gender_stats', default=None)
|
gstats = self.metadata.get('gender_stats', default=None)
|
||||||
|
|
||||||
@@ -455,18 +482,12 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
if self.need_upgrade():
|
if self.need_upgrade():
|
||||||
self.gramps_upgrade(callback)
|
self.gramps_upgrade(callback)
|
||||||
|
|
||||||
callback(50)
|
|
||||||
|
|
||||||
if not self.secondary_connected:
|
if not self.secondary_connected:
|
||||||
self.connect_secondary()
|
self.connect_secondary()
|
||||||
|
|
||||||
callback(75)
|
|
||||||
|
|
||||||
self.open_undodb()
|
self.open_undodb()
|
||||||
self.db_is_open = True
|
self.db_is_open = True
|
||||||
|
|
||||||
callback(87)
|
|
||||||
|
|
||||||
# Re-set the undo history to a fresh session start
|
# Re-set the undo history to a fresh session start
|
||||||
self.undoindex = -1
|
self.undoindex = -1
|
||||||
self.translist = [None] * len(self.translist)
|
self.translist = [None] * len(self.translist)
|
||||||
@@ -480,7 +501,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
db_copy(other_database, self, callback)
|
db_copy(other_database, self, callback)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def _load_metadata(self):
|
def __load_metadata(self):
|
||||||
# name display formats
|
# name display formats
|
||||||
self.name_formats = self.metadata.get('name_formats', default=[])
|
self.name_formats = self.metadata.get('name_formats', default=[])
|
||||||
# upgrade formats if they were saved in the old way
|
# upgrade formats if they were saved in the old way
|
||||||
@@ -554,7 +575,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
if self.readonly:
|
if self.readonly:
|
||||||
table_flags = db.DB_RDONLY
|
table_flags = db.DB_RDONLY
|
||||||
else:
|
else:
|
||||||
table_flags = self.open_flags()
|
table_flags = self.__open_flags()
|
||||||
|
|
||||||
self.surnames = db.DB(self.env)
|
self.surnames = db.DB(self.env)
|
||||||
self.surnames.set_flags(db.DB_DUP|db.DB_DUPSORT)
|
self.surnames.set_flags(db.DB_DUP|db.DB_DUPSORT)
|
||||||
@@ -619,21 +640,21 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
db.DB_BTREE, flags=table_flags)
|
db.DB_BTREE, flags=table_flags)
|
||||||
|
|
||||||
if not self.readonly:
|
if not self.readonly:
|
||||||
self.person_map.associate(self.surnames, find_surname, table_flags)
|
self.person_map.associate(self.surnames, __find_surname, table_flags)
|
||||||
self.person_map.associate(self.id_trans, find_idmap, table_flags)
|
self.person_map.associate(self.id_trans, __find_idmap, table_flags)
|
||||||
self.family_map.associate(self.fid_trans,find_idmap, table_flags)
|
self.family_map.associate(self.fid_trans, __find_idmap, table_flags)
|
||||||
self.event_map.associate(self.eid_trans, find_idmap, table_flags)
|
self.event_map.associate(self.eid_trans, __find_idmap, table_flags)
|
||||||
self.repository_map.associate(self.rid_trans, find_idmap,
|
self.repository_map.associate(self.rid_trans, __find_idmap,
|
||||||
table_flags)
|
table_flags)
|
||||||
self.note_map.associate(self.nid_trans, find_idmap, table_flags)
|
self.note_map.associate(self.nid_trans, __find_idmap, table_flags)
|
||||||
self.place_map.associate(self.pid_trans, find_idmap, table_flags)
|
self.place_map.associate(self.pid_trans, __find_idmap, table_flags)
|
||||||
self.media_map.associate(self.oid_trans, find_idmap, table_flags)
|
self.media_map.associate(self.oid_trans, __find_idmap, table_flags)
|
||||||
self.source_map.associate(self.sid_trans, find_idmap, table_flags)
|
self.source_map.associate(self.sid_trans, __find_idmap, table_flags)
|
||||||
self.reference_map.associate(self.reference_map_primary_map,
|
self.reference_map.associate(self.reference_map_primary_map,
|
||||||
find_primary_handle,
|
__find_primary_handle,
|
||||||
table_flags)
|
table_flags)
|
||||||
self.reference_map.associate(self.reference_map_referenced_map,
|
self.reference_map.associate(self.reference_map_referenced_map,
|
||||||
find_referenced_handle,
|
__find_referenced_handle,
|
||||||
table_flags)
|
table_flags)
|
||||||
self.secondary_connected = True
|
self.secondary_connected = True
|
||||||
|
|
||||||
@@ -650,7 +671,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
if self.readonly:
|
if self.readonly:
|
||||||
return
|
return
|
||||||
|
|
||||||
table_flags = self.open_flags()
|
table_flags = self.__open_flags()
|
||||||
|
|
||||||
# remove existing secondary indices
|
# remove existing secondary indices
|
||||||
self.id_trans.close()
|
self.id_trans.close()
|
||||||
@@ -775,7 +796,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _delete_primary_from_reference_map(self,handle,transaction,txn=None):
|
def __delete_primary_from_reference_map(self, hndl, transaction, txn=None):
|
||||||
"""
|
"""
|
||||||
Remove all references to the primary object from the reference_map.
|
Remove all references to the primary object from the reference_map.
|
||||||
"""
|
"""
|
||||||
@@ -783,7 +804,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
primary_cur = self.get_reference_map_primary_cursor()
|
primary_cur = self.get_reference_map_primary_cursor()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret = primary_cur.set(handle)
|
ret = primary_cur.set(hndl)
|
||||||
except:
|
except:
|
||||||
ret = None
|
ret = None
|
||||||
|
|
||||||
@@ -798,7 +819,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
# so we need the second tuple give us a reference that we can
|
# so we need the second tuple give us a reference that we can
|
||||||
# combine with the primary_handle to get the main key.
|
# combine with the primary_handle to get the main key.
|
||||||
|
|
||||||
main_key = (handle, pickle.loads(data)[1][1])
|
main_key = (hndl, pickle.loads(data)[1][1])
|
||||||
|
|
||||||
# The trick is not to remove while inside the cursor,
|
# The trick is not to remove while inside the cursor,
|
||||||
# but collect them all and remove after the cursor is closed
|
# but collect them all and remove after the cursor is closed
|
||||||
@@ -810,9 +831,9 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
|
|
||||||
# Now that the cursor is closed, we can remove things
|
# Now that the cursor is closed, we can remove things
|
||||||
for main_key in remove_list:
|
for main_key in remove_list:
|
||||||
self._remove_reference(main_key,transaction,txn)
|
self.__remove_reference(main_key, transaction, txn)
|
||||||
|
|
||||||
def _update_reference_map(self, obj, transaction, txn=None):
|
def __update_reference_map(self, obj, transaction, txn=None):
|
||||||
"""
|
"""
|
||||||
If txn is given, then changes are written right away using txn.
|
If txn is given, then changes are written right away using txn.
|
||||||
"""
|
"""
|
||||||
@@ -880,17 +901,17 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
for (ref_class_name, ref_handle) in new_references:
|
for (ref_class_name, ref_handle) in new_references:
|
||||||
data = ((CLASS_TO_KEY_MAP[obj.__class__.__name__], handle),
|
data = ((CLASS_TO_KEY_MAP[obj.__class__.__name__], handle),
|
||||||
(CLASS_TO_KEY_MAP[ref_class_name], ref_handle), )
|
(CLASS_TO_KEY_MAP[ref_class_name], ref_handle), )
|
||||||
self._add_reference((handle,ref_handle),data,transaction,txn)
|
self.__add_reference((handle, ref_handle), data, transaction, txn)
|
||||||
|
|
||||||
# handle deletion of old references
|
# handle deletion of old references
|
||||||
for (ref_class_name, ref_handle) in no_longer_required_references:
|
for (ref_class_name, ref_handle) in no_longer_required_references:
|
||||||
try:
|
try:
|
||||||
self._remove_reference((handle,ref_handle),transaction,txn)
|
self.__remove_reference((handle, ref_handle), transaction, txn)
|
||||||
except:
|
except:
|
||||||
# ignore missing old reference
|
# ignore missing old reference
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _remove_reference(self,key,transaction,txn=None):
|
def __remove_reference(self, key, transaction, txn=None):
|
||||||
"""
|
"""
|
||||||
Removes the reference specified by the key,
|
Removes the reference specified by the key,
|
||||||
preserving the change in the passed transaction.
|
preserving the change in the passed transaction.
|
||||||
@@ -905,7 +926,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
transaction.add(REFERENCE_KEY, str(key), old_data, None)
|
transaction.add(REFERENCE_KEY, str(key), old_data, None)
|
||||||
transaction.reference_del.append(str(key))
|
transaction.reference_del.append(str(key))
|
||||||
|
|
||||||
def _add_reference(self,key,data,transaction,txn=None):
|
def __add_reference(self, key, data, transaction, txn=None):
|
||||||
"""
|
"""
|
||||||
Adds the reference specified by the key and the data,
|
Adds the reference specified by the key and the data,
|
||||||
preserving the change in the passed transaction.
|
preserving the change in the passed transaction.
|
||||||
@@ -946,17 +967,17 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
callback(3)
|
callback(3)
|
||||||
|
|
||||||
# Open reference_map and primapry map
|
# Open reference_map and primapry map
|
||||||
self.reference_map = self.open_table(self.full_name, "reference_map",
|
self.reference_map = self.__open_table(self.full_name, "reference_map",
|
||||||
dbtype=db.DB_BTREE)
|
dbtype=db.DB_BTREE)
|
||||||
|
|
||||||
open_flags = self.open_flags()
|
open_flags = self.__open_flags()
|
||||||
self.reference_map_primary_map = db.DB(self.env)
|
self.reference_map_primary_map = db.DB(self.env)
|
||||||
self.reference_map_primary_map.set_flags(db.DB_DUP)
|
self.reference_map_primary_map.set_flags(db.DB_DUP)
|
||||||
self.reference_map_primary_map.open(self.full_name,
|
self.reference_map_primary_map.open(self.full_name,
|
||||||
"reference_map_primary_map",
|
"reference_map_primary_map",
|
||||||
db.DB_BTREE, flags=open_flags)
|
db.DB_BTREE, flags=open_flags)
|
||||||
self.reference_map.associate(self.reference_map_primary_map,
|
self.reference_map.associate(self.reference_map_primary_map,
|
||||||
find_primary_handle,
|
__find_primary_handle,
|
||||||
open_flags)
|
open_flags)
|
||||||
|
|
||||||
# Make a dictionary of the functions and classes that we need for
|
# Make a dictionary of the functions and classes that we need for
|
||||||
@@ -1002,7 +1023,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
the_txn = self.env.txn_begin()
|
the_txn = self.env.txn_begin()
|
||||||
else:
|
else:
|
||||||
the_txn = None
|
the_txn = None
|
||||||
self._update_reference_map(obj,transaction,the_txn)
|
self.__update_reference_map(obj, transaction, the_txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.reference_map.sync()
|
self.reference_map.sync()
|
||||||
if the_txn:
|
if the_txn:
|
||||||
@@ -1020,12 +1041,12 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
self.full_name, "reference_map_referenced_map",
|
self.full_name, "reference_map_referenced_map",
|
||||||
db.DB_BTREE, flags=open_flags)
|
db.DB_BTREE, flags=open_flags)
|
||||||
self.reference_map.associate(self.reference_map_referenced_map,
|
self.reference_map.associate(self.reference_map_referenced_map,
|
||||||
find_referenced_handle,open_flags)
|
__find_referenced_handle, open_flags)
|
||||||
callback(6)
|
callback(6)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _close_metadata(self):
|
def __close_metadata(self):
|
||||||
if not self.readonly:
|
if not self.readonly:
|
||||||
if self.UseTXN:
|
if self.UseTXN:
|
||||||
# Start transaction if needed
|
# Start transaction if needed
|
||||||
@@ -1098,7 +1119,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
|
|
||||||
self.metadata.close()
|
self.metadata.close()
|
||||||
|
|
||||||
def _close_early(self):
|
def __close_early(self):
|
||||||
"""
|
"""
|
||||||
Bail out if the incompatible version is discovered:
|
Bail out if the incompatible version is discovered:
|
||||||
* close cleanly to not damage data/env
|
* close cleanly to not damage data/env
|
||||||
@@ -1122,7 +1143,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
if self.UseTXN:
|
if self.UseTXN:
|
||||||
self.env.txn_checkpoint()
|
self.env.txn_checkpoint()
|
||||||
|
|
||||||
self._close_metadata()
|
self.__close_metadata()
|
||||||
self.name_group.close()
|
self.name_group.close()
|
||||||
self.surnames.close()
|
self.surnames.close()
|
||||||
self.id_trans.close()
|
self.id_trans.close()
|
||||||
@@ -1147,16 +1168,6 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
self.source_map.close()
|
self.source_map.close()
|
||||||
self.media_map.close()
|
self.media_map.close()
|
||||||
self.event_map.close()
|
self.event_map.close()
|
||||||
|
|
||||||
# Attempt to clear log sequence numbers, to make database portable
|
|
||||||
# This will only work for python2.5 and higher
|
|
||||||
# Comment this our because it causes crashes.
|
|
||||||
# To reproduce the crash, create a new DB, import example.gramps, open and close the db a few times.
|
|
||||||
# try:
|
|
||||||
# self.env.lsn_reset(self.full_name)
|
|
||||||
# except AttributeError:
|
|
||||||
# pass
|
|
||||||
|
|
||||||
self.env.close()
|
self.env.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -1177,7 +1188,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
self.metadata = None
|
self.metadata = None
|
||||||
self.db_is_open = False
|
self.db_is_open = False
|
||||||
|
|
||||||
def _do_remove_object(self,handle,transaction,data_map,key,del_list):
|
def __do_remove_object(self, handle, transaction, data_map, key, del_list):
|
||||||
if self.readonly or not handle:
|
if self.readonly or not handle:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1187,7 +1198,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
the_txn = self.env.txn_begin()
|
the_txn = self.env.txn_begin()
|
||||||
else:
|
else:
|
||||||
the_txn = None
|
the_txn = None
|
||||||
self._delete_primary_from_reference_map(handle,transaction,
|
self.__delete_primary_from_reference_map(handle, transaction,
|
||||||
txn=the_txn)
|
txn=the_txn)
|
||||||
data_map.delete(handle, txn=the_txn)
|
data_map.delete(handle, txn=the_txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
@@ -1195,47 +1206,47 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
if the_txn:
|
if the_txn:
|
||||||
the_txn.commit()
|
the_txn.commit()
|
||||||
else:
|
else:
|
||||||
self._delete_primary_from_reference_map(handle,transaction)
|
self.__delete_primary_from_reference_map(handle, transaction)
|
||||||
old_data = data_map.get(handle, txn=self.txn)
|
old_data = data_map.get(handle, txn=self.txn)
|
||||||
transaction.add(key, handle, old_data, None)
|
transaction.add(key, handle, old_data, None)
|
||||||
del_list.append(handle)
|
del_list.append(handle)
|
||||||
|
|
||||||
def _del_person(self,handle):
|
def __del_person(self, handle):
|
||||||
self.person_map.delete(str(handle), txn=self.txn)
|
self.person_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.person_map.sync()
|
self.person_map.sync()
|
||||||
|
|
||||||
def _del_source(self,handle):
|
def __del_source(self, handle):
|
||||||
self.source_map.delete(str(handle), txn=self.txn)
|
self.source_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.source_map.sync()
|
self.source_map.sync()
|
||||||
|
|
||||||
def _del_repository(self,handle):
|
def __del_repository(self, handle):
|
||||||
self.repository_map.delete(str(handle), txn=self.txn)
|
self.repository_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.repository_map.sync()
|
self.repository_map.sync()
|
||||||
|
|
||||||
def _del_note(self,handle):
|
def __del_note(self, handle):
|
||||||
self.note_map.delete(str(handle), txn=self.txn)
|
self.note_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.note_map.sync()
|
self.note_map.sync()
|
||||||
|
|
||||||
def _del_place(self,handle):
|
def __del_place(self, handle):
|
||||||
self.place_map.delete(str(handle), txn=self.txn)
|
self.place_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.place_map.sync()
|
self.place_map.sync()
|
||||||
|
|
||||||
def _del_media(self,handle):
|
def __del_media(self, handle):
|
||||||
self.media_map.delete(str(handle), txn=self.txn)
|
self.media_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.media_map.sync()
|
self.media_map.sync()
|
||||||
|
|
||||||
def _del_family(self,handle):
|
def __del_family(self, handle):
|
||||||
self.family_map.delete(str(handle), txn=self.txn)
|
self.family_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.family_map.sync()
|
self.family_map.sync()
|
||||||
|
|
||||||
def _del_event(self,handle):
|
def __del_event(self, handle):
|
||||||
self.event_map.delete(str(handle), txn=self.txn)
|
self.event_map.delete(str(handle), txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.event_map.sync()
|
self.event_map.sync()
|
||||||
@@ -1276,7 +1287,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _get_obj_from_gramps_id(self,val,tbl,class_init,prim_tbl):
|
def __get_obj_from_gramps_id(self, val, tbl, class_init, prim_tbl):
|
||||||
if tbl.has_key(str(val)):
|
if tbl.has_key(str(val)):
|
||||||
data = tbl.get(str(val), txn=self.txn)
|
data = tbl.get(str(val), txn=self.txn)
|
||||||
obj = class_init()
|
obj = class_init()
|
||||||
@@ -1298,7 +1309,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds a Person in the database from the passed gramps' ID.
|
Finds a Person in the database from the passed gramps' ID.
|
||||||
If no such Person exists, None is returned.
|
If no such Person exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.id_trans,Person,
|
return self.__get_obj_from_gramps_id(val, self.id_trans, Person,
|
||||||
self.person_map)
|
self.person_map)
|
||||||
|
|
||||||
def get_family_from_gramps_id(self, val):
|
def get_family_from_gramps_id(self, val):
|
||||||
@@ -1306,7 +1317,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds a Family in the database from the passed gramps' ID.
|
Finds a Family in the database from the passed gramps' ID.
|
||||||
If no such Family exists, None is return.
|
If no such Family exists, None is return.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.fid_trans,Family,
|
return self.__get_obj_from_gramps_id(val, self.fid_trans, Family,
|
||||||
self.family_map)
|
self.family_map)
|
||||||
|
|
||||||
def get_event_from_gramps_id(self, val):
|
def get_event_from_gramps_id(self, val):
|
||||||
@@ -1314,7 +1325,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds an Event in the database from the passed gramps' ID.
|
Finds an Event in the database from the passed gramps' ID.
|
||||||
If no such Family exists, None is returned.
|
If no such Family exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.eid_trans,Event,
|
return self.__get_obj_from_gramps_id(val, self.eid_trans, Event,
|
||||||
self.event_map)
|
self.event_map)
|
||||||
|
|
||||||
def get_place_from_gramps_id(self, val):
|
def get_place_from_gramps_id(self, val):
|
||||||
@@ -1322,7 +1333,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds a Place in the database from the passed gramps' ID.
|
Finds a Place in the database from the passed gramps' ID.
|
||||||
If no such Place exists, None is returned.
|
If no such Place exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.pid_trans,Place,
|
return self.__get_obj_from_gramps_id(val, self.pid_trans, Place,
|
||||||
self.place_map)
|
self.place_map)
|
||||||
|
|
||||||
def get_source_from_gramps_id(self, val):
|
def get_source_from_gramps_id(self, val):
|
||||||
@@ -1330,7 +1341,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds a Source in the database from the passed gramps' ID.
|
Finds a Source in the database from the passed gramps' ID.
|
||||||
If no such Source exists, None is returned.
|
If no such Source exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.sid_trans,Source,
|
return self.__get_obj_from_gramps_id(val, self.sid_trans, Source,
|
||||||
self.source_map)
|
self.source_map)
|
||||||
|
|
||||||
def get_object_from_gramps_id(self, val):
|
def get_object_from_gramps_id(self, val):
|
||||||
@@ -1338,7 +1349,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds a MediaObject in the database from the passed gramps' ID.
|
Finds a MediaObject in the database from the passed gramps' ID.
|
||||||
If no such MediaObject exists, None is returned.
|
If no such MediaObject exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.oid_trans,MediaObject,
|
return self.__get_obj_from_gramps_id(val, self.oid_trans, MediaObject,
|
||||||
self.media_map)
|
self.media_map)
|
||||||
|
|
||||||
def get_repository_from_gramps_id(self, val):
|
def get_repository_from_gramps_id(self, val):
|
||||||
@@ -1346,7 +1357,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds a Repository in the database from the passed gramps' ID.
|
Finds a Repository in the database from the passed gramps' ID.
|
||||||
If no such Repository exists, None is returned.
|
If no such Repository exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.rid_trans,Repository,
|
return self.__get_obj_from_gramps_id(val, self.rid_trans, Repository,
|
||||||
self.repository_map)
|
self.repository_map)
|
||||||
|
|
||||||
def get_note_from_gramps_id(self, val):
|
def get_note_from_gramps_id(self, val):
|
||||||
@@ -1354,10 +1365,10 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
Finds a Note in the database from the passed gramps' ID.
|
Finds a Note in the database from the passed gramps' ID.
|
||||||
If no such Note exists, None is returned.
|
If no such Note exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_obj_from_gramps_id(val,self.nid_trans,Note,
|
return self.__get_obj_from_gramps_id(val, self.nid_trans, Note,
|
||||||
self.note_map)
|
self.note_map)
|
||||||
|
|
||||||
def _commit_base(self, obj, data_map, key, update_list, add_list,
|
def __commit_base(self, obj, data_map, key, update_list, add_list,
|
||||||
transaction, change_time):
|
transaction, change_time):
|
||||||
"""
|
"""
|
||||||
Commits the specified object to the database, storing the changes
|
Commits the specified object to the database, storing the changes
|
||||||
@@ -1377,7 +1388,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
the_txn = self.env.txn_begin()
|
the_txn = self.env.txn_begin()
|
||||||
else:
|
else:
|
||||||
the_txn = None
|
the_txn = None
|
||||||
self._update_reference_map(obj,transaction,txn=the_txn)
|
self.__update_reference_map(obj, transaction, txn=the_txn)
|
||||||
data_map.put(handle, obj.serialize(), txn=the_txn)
|
data_map.put(handle, obj.serialize(), txn=the_txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
data_map.sync()
|
data_map.sync()
|
||||||
@@ -1385,7 +1396,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
the_txn.commit()
|
the_txn.commit()
|
||||||
old_data = None
|
old_data = None
|
||||||
else:
|
else:
|
||||||
self._update_reference_map(obj,transaction)
|
self.__update_reference_map(obj, transaction)
|
||||||
old_data = data_map.get(handle, txn=self.txn)
|
old_data = data_map.get(handle, txn=self.txn)
|
||||||
new_data = obj.serialize()
|
new_data = obj.serialize()
|
||||||
transaction.add(key, handle, old_data, new_data)
|
transaction.add(key, handle, old_data, new_data)
|
||||||
@@ -1395,7 +1406,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
add_list.append((handle, new_data))
|
add_list.append((handle, new_data))
|
||||||
return old_data
|
return old_data
|
||||||
|
|
||||||
def _do_commit(self,add_list,db_map):
|
def __do_commit(self, add_list, db_map):
|
||||||
retlist = []
|
retlist = []
|
||||||
for (handle, data) in add_list:
|
for (handle, data) in add_list:
|
||||||
db_map.put(handle, data, self.txn)
|
db_map.put(handle, data, self.txn)
|
||||||
@@ -1404,7 +1415,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
retlist.append(str(handle))
|
retlist.append(str(handle))
|
||||||
return retlist
|
return retlist
|
||||||
|
|
||||||
def _get_from_handle(self, handle, class_type, data_map):
|
def __get_from_handle(self, handle, class_type, data_map):
|
||||||
try:
|
try:
|
||||||
data = data_map.get(str(handle), txn=self.txn)
|
data = data_map.get(str(handle), txn=self.txn)
|
||||||
except:
|
except:
|
||||||
@@ -1412,21 +1423,21 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
# under certain circumstances during a database reload,
|
# under certain circumstances during a database reload,
|
||||||
# data_map can be none. If so, then don't report an error
|
# data_map can be none. If so, then don't report an error
|
||||||
if data_map:
|
if data_map:
|
||||||
log.error("Failed to get from handle",exc_info=True)
|
__LOG.error("Failed to get from handle", exc_info=True)
|
||||||
if data:
|
if data:
|
||||||
newobj = class_type()
|
newobj = class_type()
|
||||||
newobj.unserialize(data)
|
newobj.unserialize(data)
|
||||||
return newobj
|
return newobj
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _find_from_handle(self,handle,transaction,class_type,dmap,add_func):
|
def __find_from_handle(self, hndl, transaction, class_type, dmap, add_func):
|
||||||
obj = class_type()
|
obj = class_type()
|
||||||
handle = str(handle)
|
hndl = str(hndl)
|
||||||
if dmap.has_key(handle):
|
if dmap.has_key(hndl):
|
||||||
data = dmap.get(handle,txn=self.txn)
|
data = dmap.get(hndl, txn=self.txn)
|
||||||
obj.unserialize(data)
|
obj.unserialize(data)
|
||||||
else:
|
else:
|
||||||
obj.set_handle(handle)
|
obj.set_handle(hndl)
|
||||||
add_func(obj, transaction)
|
add_func(obj, transaction)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
@@ -1492,14 +1503,14 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
|
|
||||||
if not transaction.no_magic:
|
if not transaction.no_magic:
|
||||||
# create new secondary indices to replace the ones removed
|
# create new secondary indices to replace the ones removed
|
||||||
open_flags = self.open_flags()
|
open_flags = self.__open_flags()
|
||||||
dupe_flags = db.DB_DUP|db.DB_DUPSORT
|
dupe_flags = db.DB_DUP|db.DB_DUPSORT
|
||||||
|
|
||||||
self.surnames = db.DB(self.env)
|
self.surnames = db.DB(self.env)
|
||||||
self.surnames.set_flags(dupe_flags)
|
self.surnames.set_flags(dupe_flags)
|
||||||
self.surnames.open(self.full_name, "surnames",
|
self.surnames.open(self.full_name, "surnames",
|
||||||
db.DB_BTREE, flags=open_flags)
|
db.DB_BTREE, flags=open_flags)
|
||||||
self.person_map.associate(self.surnames,find_surname,
|
self.person_map.associate(self.surnames, __find_surname,
|
||||||
open_flags)
|
open_flags)
|
||||||
|
|
||||||
self.reference_map_referenced_map = db.DB(self.env)
|
self.reference_map_referenced_map = db.DB(self.env)
|
||||||
@@ -1508,7 +1519,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
self.full_name, "reference_map_referenced_map",
|
self.full_name, "reference_map_referenced_map",
|
||||||
db.DB_BTREE, flags=open_flags)
|
db.DB_BTREE, flags=open_flags)
|
||||||
self.reference_map.associate(self.reference_map_referenced_map,
|
self.reference_map.associate(self.reference_map_referenced_map,
|
||||||
find_referenced_handle,open_flags)
|
__find_referenced_handle, open_flags)
|
||||||
|
|
||||||
# Only build surname list after surname index is surely back
|
# Only build surname list after surname index is surely back
|
||||||
self.build_surname_list()
|
self.build_surname_list()
|
||||||
@@ -1802,8 +1813,8 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
|
|
||||||
new_alt_loc = [convert_location_11(loc) for loc in alt_loc]
|
new_alt_loc = [convert_location_11(loc) for loc in alt_loc]
|
||||||
|
|
||||||
info = (handle,gramps_id,title,long,lat,main_loc,new_alt_loc,urls,
|
info = (handle, gramps_id, title, long, lat, main_loc, new_alt_loc,
|
||||||
media_list, source_list, note, change, marker, private)
|
urls, media_list, source_list, note, change, marker, private)
|
||||||
|
|
||||||
if self.UseTXN:
|
if self.UseTXN:
|
||||||
the_txn = self.env.txn_begin()
|
the_txn = self.env.txn_begin()
|
||||||
@@ -1835,12 +1846,12 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
def gramps_upgrade_12(self):
|
def gramps_upgrade_12(self):
|
||||||
print "Upgrading to DB version 12..."
|
print "Upgrading to DB version 12..."
|
||||||
# Hook up surnames
|
# Hook up surnames
|
||||||
table_flags = self.open_flags()
|
table_flags = self.__open_flags()
|
||||||
self.surnames = db.DB(self.env)
|
self.surnames = db.DB(self.env)
|
||||||
self.surnames.set_flags(db.DB_DUP|db.DB_DUPSORT)
|
self.surnames.set_flags(db.DB_DUP|db.DB_DUPSORT)
|
||||||
self.surnames.open(self.full_name, "surnames", db.DB_BTREE,
|
self.surnames.open(self.full_name, "surnames", db.DB_BTREE,
|
||||||
flags=table_flags)
|
flags=table_flags)
|
||||||
self.person_map.associate(self.surnames, find_surname, table_flags)
|
self.person_map.associate(self.surnames, __find_surname, table_flags)
|
||||||
|
|
||||||
self.build_surname_list()
|
self.build_surname_list()
|
||||||
|
|
||||||
@@ -1867,12 +1878,12 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
print "Upgrading to DB version 13..."
|
print "Upgrading to DB version 13..."
|
||||||
# Hook up note id index
|
# Hook up note id index
|
||||||
table_flags = self.open_flags()
|
table_flags = self.__open_flags()
|
||||||
self.nid_trans = db.DB(self.env)
|
self.nid_trans = db.DB(self.env)
|
||||||
self.nid_trans.set_flags(db.DB_DUP)
|
self.nid_trans.set_flags(db.DB_DUP)
|
||||||
self.nid_trans.open(self.full_name, "nidtrans",
|
self.nid_trans.open(self.full_name, "nidtrans",
|
||||||
db.DB_HASH, flags=table_flags)
|
db.DB_HASH, flags=table_flags)
|
||||||
self.note_map.associate(self.nid_trans, find_idmap, table_flags)
|
self.note_map.associate(self.nid_trans, __find_idmap, table_flags)
|
||||||
|
|
||||||
# This upgrade modifies repos (store change attribute)
|
# This upgrade modifies repos (store change attribute)
|
||||||
# And converts notes to the list of handles in all records
|
# And converts notes to the list of handles in all records
|
||||||
@@ -1969,7 +1980,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
"reference_map_primary_map",
|
"reference_map_primary_map",
|
||||||
db.DB_BTREE, flags=table_flags)
|
db.DB_BTREE, flags=table_flags)
|
||||||
self.reference_map.associate(self.reference_map_primary_map,
|
self.reference_map.associate(self.reference_map_primary_map,
|
||||||
find_primary_handle,
|
__find_primary_handle,
|
||||||
table_flags)
|
table_flags)
|
||||||
self.reference_map_primary_map.close()
|
self.reference_map_primary_map.close()
|
||||||
|
|
||||||
@@ -1981,7 +1992,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
"reference_map_referenced_map",
|
"reference_map_referenced_map",
|
||||||
db.DB_BTREE, flags=table_flags)
|
db.DB_BTREE, flags=table_flags)
|
||||||
self.reference_map.associate(self.reference_map_referenced_map,
|
self.reference_map.associate(self.reference_map_referenced_map,
|
||||||
find_referenced_handle,
|
__find_referenced_handle,
|
||||||
table_flags)
|
table_flags)
|
||||||
self.reference_map_referenced_map.close()
|
self.reference_map_referenced_map.close()
|
||||||
|
|
||||||
@@ -2336,20 +2347,3 @@ def convert_location_11(loc):
|
|||||||
street = u''
|
street = u''
|
||||||
new_location_base = (street, city, county, state, country, postal, phone)
|
new_location_base = (street, city, county, state, country, postal, phone)
|
||||||
return (new_location_base, parish)
|
return (new_location_base, parish)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
d = GrampsBSDDB()
|
|
||||||
d.load(sys.argv[1],lambda x: x)
|
|
||||||
|
|
||||||
c = d.get_person_cursor()
|
|
||||||
data = c.first()
|
|
||||||
while data:
|
|
||||||
person = Person(data[1])
|
|
||||||
print data[0], person.get_primary_name().get_name(),
|
|
||||||
data = c.next()
|
|
||||||
c.close()
|
|
||||||
|
|
||||||
print d.surnames.keys()
|
|
||||||
|
@@ -51,6 +51,7 @@ from _DbUtils import db_copy
|
|||||||
import _GrampsDbConst as const
|
import _GrampsDbConst as const
|
||||||
from _GrampsDbExceptions import FileVersionError
|
from _GrampsDbExceptions import FileVersionError
|
||||||
from BasicUtils import UpdateCallback
|
from BasicUtils import UpdateCallback
|
||||||
|
from _GrampsCursor import GrampsCursor
|
||||||
|
|
||||||
_MINVERSION = 9
|
_MINVERSION = 9
|
||||||
_DBVERSION = 13
|
_DBVERSION = 13
|
||||||
@@ -1168,42 +1169,42 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
|||||||
transaction.add(key,handle,old_data,None)
|
transaction.add(key,handle,old_data,None)
|
||||||
del_list.append(handle)
|
del_list.append(handle)
|
||||||
|
|
||||||
def _del_person(self,handle):
|
def __del_person(self,handle):
|
||||||
self.person_map.delete(str(handle),txn=self.txn)
|
self.person_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.person_map.sync()
|
self.person_map.sync()
|
||||||
|
|
||||||
def _del_source(self,handle):
|
def __del_source(self,handle):
|
||||||
self.source_map.delete(str(handle),txn=self.txn)
|
self.source_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.source_map.sync()
|
self.source_map.sync()
|
||||||
|
|
||||||
def _del_repository(self,handle):
|
def __del_repository(self,handle):
|
||||||
self.repository_map.delete(str(handle),txn=self.txn)
|
self.repository_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.repository_map.sync()
|
self.repository_map.sync()
|
||||||
|
|
||||||
def _del_note(self,handle):
|
def __del_note(self,handle):
|
||||||
self.note_map.delete(str(handle),txn=self.txn)
|
self.note_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.note_map.sync()
|
self.note_map.sync()
|
||||||
|
|
||||||
def _del_place(self,handle):
|
def __del_place(self,handle):
|
||||||
self.place_map.delete(str(handle),txn=self.txn)
|
self.place_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.place_map.sync()
|
self.place_map.sync()
|
||||||
|
|
||||||
def _del_media(self,handle):
|
def __del_media(self,handle):
|
||||||
self.media_map.delete(str(handle),txn=self.txn)
|
self.media_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.media_map.sync()
|
self.media_map.sync()
|
||||||
|
|
||||||
def _del_family(self,handle):
|
def __del_family(self,handle):
|
||||||
self.family_map.delete(str(handle),txn=self.txn)
|
self.family_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.family_map.sync()
|
self.family_map.sync()
|
||||||
|
|
||||||
def _del_event(self,handle):
|
def __del_event(self,handle):
|
||||||
self.event_map.delete(str(handle),txn=self.txn)
|
self.event_map.delete(str(handle),txn=self.txn)
|
||||||
if not self.UseTXN:
|
if not self.UseTXN:
|
||||||
self.event_map.sync()
|
self.event_map.sync()
|
||||||
@@ -1325,7 +1326,7 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
|||||||
return self._get_obj_from_gramps_id(val,self.nid_trans,Note,
|
return self._get_obj_from_gramps_id(val,self.nid_trans,Note,
|
||||||
self.note_map)
|
self.note_map)
|
||||||
|
|
||||||
def _commit_base(self, obj, data_map, key, update_list, add_list,
|
def __commit_base(self, obj, data_map, key, update_list, add_list,
|
||||||
transaction, change_time):
|
transaction, change_time):
|
||||||
"""
|
"""
|
||||||
Commits the specified object to the database, storing the changes
|
Commits the specified object to the database, storing the changes
|
||||||
|
@@ -43,7 +43,7 @@ from bsddb import db
|
|||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(".GrampsDb")
|
LOG = logging.getLogger(".GrampsDb")
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -60,6 +60,7 @@ from _CursorIterator import CursorIterator
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from _GrampsDbConst import *
|
from _GrampsDbConst import *
|
||||||
|
from _GrampsCursor import GrampsCursor
|
||||||
|
|
||||||
_UNDO_SIZE = 1000
|
_UNDO_SIZE = 1000
|
||||||
|
|
||||||
@@ -88,61 +89,9 @@ KEY_TO_CLASS_MAP = {PERSON_KEY: Person.__name__,
|
|||||||
REPOSITORY_KEY: Repository.__name__,
|
REPOSITORY_KEY: Repository.__name__,
|
||||||
NOTE_KEY: Note.__name__}
|
NOTE_KEY: Note.__name__}
|
||||||
|
|
||||||
_sigbase = ('person', 'family', 'source', 'event',
|
__SIGBASE = ('person', 'family', 'source', 'event',
|
||||||
'media', 'place', 'repository','note')
|
'media', 'place', 'repository','note')
|
||||||
|
|
||||||
class GrampsCursor:
|
|
||||||
"""
|
|
||||||
Provides a basic iterator that allows the user to cycle through
|
|
||||||
the elements in a particular map. A cursor should never be
|
|
||||||
directly instantiated. Instead, in should be created by the
|
|
||||||
database class.
|
|
||||||
|
|
||||||
A cursor should only be used for a single pass through the
|
|
||||||
database. If multiple passes are needed, multiple cursors
|
|
||||||
should be used.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def first(self):
|
|
||||||
"""
|
|
||||||
Returns the first (index, data) pair in the database. This
|
|
||||||
should be called before the first call to next(). Note that
|
|
||||||
the data return is in the format of the serialized format
|
|
||||||
stored in the database, not in the more usable class object.
|
|
||||||
The data should be converted to a class using the class's
|
|
||||||
unserialize method.
|
|
||||||
|
|
||||||
If no data is available, None is returned.
|
|
||||||
"""
|
|
||||||
return None
|
|
||||||
|
|
||||||
def next(self):
|
|
||||||
"""
|
|
||||||
Returns the next (index, data) pair in the database. Like
|
|
||||||
the first() method, the data return is in the format of the
|
|
||||||
serialized format stored in the database, not in the more
|
|
||||||
usable class object. The data should be converted to a class
|
|
||||||
using the class's unserialize method.
|
|
||||||
|
|
||||||
None is returned when no more data is available.
|
|
||||||
"""
|
|
||||||
return None
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
"""
|
|
||||||
Closes the cursor. This should be called when the user is
|
|
||||||
finished using the cursor, freeing up the cursor's resources.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_length(self):
|
|
||||||
"""
|
|
||||||
Returns the number of records in the table referenced by the
|
|
||||||
cursor
|
|
||||||
"""
|
|
||||||
raise NotImplementedError, \
|
|
||||||
"get_length must be implemented by all subclasses of GrampsCursor"
|
|
||||||
|
|
||||||
class GrampsDbBookmarks:
|
class GrampsDbBookmarks:
|
||||||
def __init__(self, default = []):
|
def __init__(self, default = []):
|
||||||
self.bookmarks = default
|
self.bookmarks = default
|
||||||
@@ -216,7 +165,6 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
'long-op-end' : None
|
'long-op-end' : None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# If this is True logging will be turned on.
|
# If this is True logging will be turned on.
|
||||||
try:
|
try:
|
||||||
__LOG_ALL = int(os.environ.get('GRAMPS_SIGNAL', "0")) == 1
|
__LOG_ALL = int(os.environ.get('GRAMPS_SIGNAL', "0")) == 1
|
||||||
@@ -272,26 +220,26 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
self.open = 0
|
self.open = 0
|
||||||
self.genderStats = GenderStats()
|
self.genderStats = GenderStats()
|
||||||
|
|
||||||
self.undodb = None
|
self.undodb = []
|
||||||
self.id_trans = None
|
self.id_trans = {}
|
||||||
self.fid_trans = None
|
self.fid_trans = {}
|
||||||
self.pid_trans = None
|
self.pid_trans = {}
|
||||||
self.sid_trans = None
|
self.sid_trans = {}
|
||||||
self.oid_trans = None
|
self.oid_trans = {}
|
||||||
self.rid_trans = None
|
self.rid_trans = {}
|
||||||
self.nid_trans = None
|
self.nid_trans = {}
|
||||||
self.eid_trans = None
|
self.eid_trans = {}
|
||||||
self.env = None
|
self.env = None
|
||||||
self.person_map = None
|
self.person_map = {}
|
||||||
self.family_map = None
|
self.family_map = {}
|
||||||
self.place_map = None
|
self.place_map = {}
|
||||||
self.source_map = None
|
self.source_map = {}
|
||||||
self.repository_map = None
|
self.repository_map = {}
|
||||||
self.note_map = None
|
self.note_map = {}
|
||||||
self.media_map = None
|
self.media_map = {}
|
||||||
self.event_map = None
|
self.event_map = {}
|
||||||
self.metadata = None
|
self.metadata = {}
|
||||||
self.name_group = None
|
self.name_group = {}
|
||||||
self.undo_callback = None
|
self.undo_callback = None
|
||||||
self.redo_callback = None
|
self.redo_callback = None
|
||||||
self.undo_history_callback = None
|
self.undo_history_callback = None
|
||||||
@@ -340,28 +288,28 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
def gramps_upgrade(self):
|
def gramps_upgrade(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_person(self, handle):
|
def __del_person(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_source(self, handle):
|
def __del_source(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_repository(self, handle):
|
def __del_repository(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_note(self, handle):
|
def __del_note(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_place(self, handle):
|
def __del_place(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_media(self, handle):
|
def __del_media(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_family(self, handle):
|
def __del_family(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _del_event(self, handle):
|
def __del_event(self, handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_id(self):
|
def create_id(self):
|
||||||
@@ -472,7 +420,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
self.emit('repository-rebuild')
|
self.emit('repository-rebuild')
|
||||||
self.emit('note-rebuild')
|
self.emit('note-rebuild')
|
||||||
|
|
||||||
def _commit_base(self, obj, data_map, key, update_list, add_list,
|
def __commit_base(self, obj, data_map, key, update_list, add_list,
|
||||||
transaction, change_time):
|
transaction, change_time):
|
||||||
"""
|
"""
|
||||||
Commits the specified Person to the database, storing the changes
|
Commits the specified Person to the database, storing the changes
|
||||||
@@ -487,7 +435,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
obj.change = int(time.time())
|
obj.change = int(time.time())
|
||||||
handle = str(obj.handle)
|
handle = str(obj.handle)
|
||||||
|
|
||||||
self._update_reference_map(obj, transaction)
|
self.__update_reference_map(obj, transaction)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if transaction.batch:
|
if transaction.batch:
|
||||||
@@ -516,7 +464,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
as part of the transaction.
|
as part of the transaction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
old_data = self._commit_base(
|
old_data = self.__commit_base(
|
||||||
person, self.person_map, PERSON_KEY, transaction.person_update,
|
person, self.person_map, PERSON_KEY, transaction.person_update,
|
||||||
transaction.person_add, transaction, change_time)
|
transaction.person_add, transaction, change_time)
|
||||||
if old_data:
|
if old_data:
|
||||||
@@ -563,7 +511,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
as part of the transaction.
|
as part of the transaction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._commit_base(obj, self.media_map, MEDIA_KEY,
|
self.__commit_base(obj, self.media_map, MEDIA_KEY,
|
||||||
transaction.media_update, transaction.media_add,
|
transaction.media_update, transaction.media_add,
|
||||||
transaction, change_time)
|
transaction, change_time)
|
||||||
self.media_attributes.update(
|
self.media_attributes.update(
|
||||||
@@ -576,7 +524,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
as part of the transaction.
|
as part of the transaction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._commit_base(source, self.source_map, SOURCE_KEY,
|
self.__commit_base(source, self.source_map, SOURCE_KEY,
|
||||||
transaction.source_update, transaction.source_add,
|
transaction.source_update, transaction.source_add,
|
||||||
transaction, change_time)
|
transaction, change_time)
|
||||||
|
|
||||||
@@ -596,7 +544,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
as part of the transaction.
|
as part of the transaction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._commit_base(place, self.place_map, PLACE_KEY,
|
self.__commit_base(place, self.place_map, PLACE_KEY,
|
||||||
transaction.place_update, transaction.place_add,
|
transaction.place_update, transaction.place_add,
|
||||||
transaction, change_time)
|
transaction, change_time)
|
||||||
|
|
||||||
@@ -624,7 +572,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Commits the specified Event to the database, storing the changes
|
Commits the specified Event to the database, storing the changes
|
||||||
as part of the transaction.
|
as part of the transaction.
|
||||||
"""
|
"""
|
||||||
self._commit_base(event, self.event_map, EVENT_KEY,
|
self.__commit_base(event, self.event_map, EVENT_KEY,
|
||||||
transaction.event_update, transaction.event_add,
|
transaction.event_update, transaction.event_add,
|
||||||
transaction, change_time)
|
transaction, change_time)
|
||||||
|
|
||||||
@@ -640,7 +588,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
as part of the transaction.
|
as part of the transaction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._commit_base(family, self.family_map, FAMILY_KEY,
|
self.__commit_base(family, self.family_map, FAMILY_KEY,
|
||||||
transaction.family_update, transaction.family_add,
|
transaction.family_update, transaction.family_add,
|
||||||
transaction, change_time)
|
transaction, change_time)
|
||||||
|
|
||||||
@@ -675,7 +623,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
as part of the transaction.
|
as part of the transaction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._commit_base(repository, self.repository_map, REPOSITORY_KEY,
|
self.__commit_base(repository, self.repository_map, REPOSITORY_KEY,
|
||||||
transaction.repository_update,
|
transaction.repository_update,
|
||||||
transaction.repository_add,
|
transaction.repository_add,
|
||||||
transaction, change_time)
|
transaction, change_time)
|
||||||
@@ -695,7 +643,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
import traceback
|
import traceback
|
||||||
traceback.print_stack()
|
traceback.print_stack()
|
||||||
|
|
||||||
self._commit_base(note, self.note_map, NOTE_KEY,
|
self.__commit_base(note, self.note_map, NOTE_KEY,
|
||||||
transaction.note_update,
|
transaction.note_update,
|
||||||
transaction.note_add,
|
transaction.note_add,
|
||||||
transaction, change_time)
|
transaction, change_time)
|
||||||
@@ -799,7 +747,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
self.nmap_index += 1
|
self.nmap_index += 1
|
||||||
return index
|
return index
|
||||||
|
|
||||||
def _get_from_handle(self, handle, class_type, data_map):
|
def __get_from_handle(self, handle, class_type, data_map):
|
||||||
if not data_map:
|
if not data_map:
|
||||||
return
|
return
|
||||||
data = data_map.get(str(handle))
|
data = data_map.get(str(handle))
|
||||||
@@ -814,56 +762,56 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Finds a Person in the database from the passed gramps' ID.
|
Finds a Person in the database from the passed gramps' ID.
|
||||||
If no such Person exists, None is returned.
|
If no such Person exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, Person, self.person_map)
|
return self.__get_from_handle(handle, Person, self.person_map)
|
||||||
|
|
||||||
def get_source_from_handle(self, handle):
|
def get_source_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
Finds a Source in the database from the passed gramps' ID.
|
Finds a Source in the database from the passed gramps' ID.
|
||||||
If no such Source exists, None is returned.
|
If no such Source exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, Source, self.source_map)
|
return self.__get_from_handle(handle, Source, self.source_map)
|
||||||
|
|
||||||
def get_object_from_handle(self, handle):
|
def get_object_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
Finds an Object in the database from the passed gramps' ID.
|
Finds an Object in the database from the passed gramps' ID.
|
||||||
If no such Object exists, None is returned.
|
If no such Object exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, MediaObject, self.media_map)
|
return self.__get_from_handle(handle, MediaObject, self.media_map)
|
||||||
|
|
||||||
def get_place_from_handle(self, handle):
|
def get_place_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
Finds a Place in the database from the passed gramps' ID.
|
Finds a Place in the database from the passed gramps' ID.
|
||||||
If no such Place exists, None is returned.
|
If no such Place exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, Place, self.place_map)
|
return self.__get_from_handle(handle, Place, self.place_map)
|
||||||
|
|
||||||
def get_event_from_handle(self, handle):
|
def get_event_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
Finds a Event in the database from the passed gramps' ID.
|
Finds a Event in the database from the passed gramps' ID.
|
||||||
If no such Event exists, None is returned.
|
If no such Event exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, Event, self.event_map)
|
return self.__get_from_handle(handle, Event, self.event_map)
|
||||||
|
|
||||||
def get_family_from_handle(self, handle):
|
def get_family_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
Finds a Family in the database from the passed gramps' ID.
|
Finds a Family in the database from the passed gramps' ID.
|
||||||
If no such Family exists, None is returned.
|
If no such Family exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, Family, self.family_map)
|
return self.__get_from_handle(handle, Family, self.family_map)
|
||||||
|
|
||||||
def get_repository_from_handle(self, handle):
|
def get_repository_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
Finds a Repository in the database from the passed gramps' ID.
|
Finds a Repository in the database from the passed gramps' ID.
|
||||||
If no such Repository exists, None is returned.
|
If no such Repository exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, Repository, self.repository_map)
|
return self.__get_from_handle(handle, Repository, self.repository_map)
|
||||||
|
|
||||||
def get_note_from_handle(self, handle):
|
def get_note_from_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
Finds a Note in the database from the passed gramps' ID.
|
Finds a Note in the database from the passed gramps' ID.
|
||||||
If no such Note exists, None is returned.
|
If no such Note exists, None is returned.
|
||||||
"""
|
"""
|
||||||
return self._get_from_handle(handle, Note, self.note_map)
|
return self.__get_from_handle(handle, Note, self.note_map)
|
||||||
|
|
||||||
def _find_from_handle(self, handle, transaction, class_type, dmap,
|
def _find_from_handle(self, handle, transaction, class_type, dmap,
|
||||||
add_func):
|
add_func):
|
||||||
@@ -876,7 +824,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
add_func(obj, transaction)
|
add_func(obj, transaction)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def _check_from_handle(self, handle, transaction, class_type, dmap,
|
def __check_from_handle(self, handle, transaction, class_type, dmap,
|
||||||
add_func):
|
add_func):
|
||||||
handle = str(handle)
|
handle = str(handle)
|
||||||
if not dmap.has_key(handle):
|
if not dmap.has_key(handle):
|
||||||
@@ -953,7 +901,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Checks whether a Person with the passed handle exists in the database.
|
Checks whether a Person with the passed handle exists in the database.
|
||||||
If no such Person exists, a new Person is added to the database.
|
If no such Person exists, a new Person is added to the database.
|
||||||
"""
|
"""
|
||||||
self._check_from_handle(handle, transaction, Person,
|
self.__check_from_handle(handle, transaction, Person,
|
||||||
self.person_map, self.add_person)
|
self.person_map, self.add_person)
|
||||||
|
|
||||||
def check_source_from_handle(self, handle, transaction):
|
def check_source_from_handle(self, handle, transaction):
|
||||||
@@ -961,7 +909,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Checks whether a Source with the passed handle exists in the database.
|
Checks whether a Source with the passed handle exists in the database.
|
||||||
If no such Source exists, a new Source is added to the database.
|
If no such Source exists, a new Source is added to the database.
|
||||||
"""
|
"""
|
||||||
self._check_from_handle(handle, transaction, Source,
|
self.__check_from_handle(handle, transaction, Source,
|
||||||
self.source_map, self.add_source)
|
self.source_map, self.add_source)
|
||||||
|
|
||||||
def check_event_from_handle(self, handle, transaction):
|
def check_event_from_handle(self, handle, transaction):
|
||||||
@@ -969,7 +917,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Checks whether an Event with the passed handle exists in the database.
|
Checks whether an Event with the passed handle exists in the database.
|
||||||
If no such Event exists, a new Event is added to the database.
|
If no such Event exists, a new Event is added to the database.
|
||||||
"""
|
"""
|
||||||
self._check_from_handle(handle, transaction, Event,
|
self.__check_from_handle(handle, transaction, Event,
|
||||||
self.event_map, self.add_event)
|
self.event_map, self.add_event)
|
||||||
|
|
||||||
def check_object_from_handle(self, handle, transaction):
|
def check_object_from_handle(self, handle, transaction):
|
||||||
@@ -979,7 +927,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
added to the database.
|
added to the database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._check_from_handle(handle, transaction, MediaObject,
|
self.__check_from_handle(handle, transaction, MediaObject,
|
||||||
self.media_map, self.add_object)
|
self.media_map, self.add_object)
|
||||||
|
|
||||||
def check_place_from_handle(self, handle, transaction):
|
def check_place_from_handle(self, handle, transaction):
|
||||||
@@ -987,7 +935,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Checks whether a Place with the passed handle exists in the database.
|
Checks whether a Place with the passed handle exists in the database.
|
||||||
If no such Place exists, a new Place is added to the database.
|
If no such Place exists, a new Place is added to the database.
|
||||||
"""
|
"""
|
||||||
self._check_from_handle(handle, transaction, Place,
|
self.__check_from_handle(handle, transaction, Place,
|
||||||
self.place_map, self.add_place)
|
self.place_map, self.add_place)
|
||||||
|
|
||||||
def check_family_from_handle(self, handle, transaction):
|
def check_family_from_handle(self, handle, transaction):
|
||||||
@@ -995,7 +943,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Checks whether a Family with the passed handle exists in the database.
|
Checks whether a Family with the passed handle exists in the database.
|
||||||
If no such Family exists, a new Family is added to the database.
|
If no such Family exists, a new Family is added to the database.
|
||||||
"""
|
"""
|
||||||
self._check_from_handle(handle, transaction, Family,
|
self.__check_from_handle(handle, transaction, Family,
|
||||||
self.family_map, self.add_family)
|
self.family_map, self.add_family)
|
||||||
|
|
||||||
def check_repository_from_handle(self, handle, transaction):
|
def check_repository_from_handle(self, handle, transaction):
|
||||||
@@ -1004,7 +952,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database. If no such Repository exists, a new Repository is added
|
database. If no such Repository exists, a new Repository is added
|
||||||
to the database.
|
to the database.
|
||||||
"""
|
"""
|
||||||
self._check_from_handle(handle, transaction, Repository,
|
self.__check_from_handle(handle, transaction, Repository,
|
||||||
self.repository_map, self.add_repository)
|
self.repository_map, self.add_repository)
|
||||||
|
|
||||||
def check_note_from_handle(self, handle, transaction):
|
def check_note_from_handle(self, handle, transaction):
|
||||||
@@ -1013,7 +961,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database. If no such Note exists, a new Note is added
|
database. If no such Note exists, a new Note is added
|
||||||
to the database.
|
to the database.
|
||||||
"""
|
"""
|
||||||
self._check_from_handle(handle, transaction, Note,
|
self.__check_from_handle(handle, transaction, Note,
|
||||||
self.note_map, self.add_note)
|
self.note_map, self.add_note)
|
||||||
|
|
||||||
def get_person_from_gramps_id(self, val):
|
def get_person_from_gramps_id(self, val):
|
||||||
@@ -1088,7 +1036,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _add_object(self, obj, transaction, find_next_func, commit_func):
|
def __add_object(self, obj, transaction, find_next_func, commit_func):
|
||||||
if not obj.gramps_id:
|
if not obj.gramps_id:
|
||||||
obj.gramps_id = find_next_func()
|
obj.gramps_id = find_next_func()
|
||||||
if not obj.handle:
|
if not obj.handle:
|
||||||
@@ -1103,7 +1051,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds a Person to the database, assigning internal IDs if they have
|
Adds a Person to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(person, transaction,
|
return self.__add_object(person, transaction,
|
||||||
self.find_next_person_gramps_id,
|
self.find_next_person_gramps_id,
|
||||||
self.commit_person)
|
self.commit_person)
|
||||||
|
|
||||||
@@ -1112,7 +1060,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds a Family to the database, assigning internal IDs if they have
|
Adds a Family to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(family, transaction,
|
return self.__add_object(family, transaction,
|
||||||
self.find_next_family_gramps_id,
|
self.find_next_family_gramps_id,
|
||||||
self.commit_family)
|
self.commit_family)
|
||||||
|
|
||||||
@@ -1121,7 +1069,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds a Source to the database, assigning internal IDs if they have
|
Adds a Source to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(source, transaction,
|
return self.__add_object(source, transaction,
|
||||||
self.find_next_source_gramps_id,
|
self.find_next_source_gramps_id,
|
||||||
self.commit_source)
|
self.commit_source)
|
||||||
|
|
||||||
@@ -1130,7 +1078,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds an Event to the database, assigning internal IDs if they have
|
Adds an Event to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(event, transaction,
|
return self.__add_object(event, transaction,
|
||||||
self.find_next_event_gramps_id,
|
self.find_next_event_gramps_id,
|
||||||
self.commit_event)
|
self.commit_event)
|
||||||
|
|
||||||
@@ -1157,7 +1105,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds a Place to the database, assigning internal IDs if they have
|
Adds a Place to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(place, transaction,
|
return self.__add_object(place, transaction,
|
||||||
self.find_next_place_gramps_id,
|
self.find_next_place_gramps_id,
|
||||||
self.commit_place)
|
self.commit_place)
|
||||||
|
|
||||||
@@ -1166,7 +1114,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds a MediaObject to the database, assigning internal IDs if they have
|
Adds a MediaObject to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(obj, transaction,
|
return self.__add_object(obj, transaction,
|
||||||
self.find_next_object_gramps_id,
|
self.find_next_object_gramps_id,
|
||||||
self.commit_media_object)
|
self.commit_media_object)
|
||||||
|
|
||||||
@@ -1175,7 +1123,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds a Repository to the database, assigning internal IDs if they have
|
Adds a Repository to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(obj, transaction,
|
return self.__add_object(obj, transaction,
|
||||||
self.find_next_repository_gramps_id,
|
self.find_next_repository_gramps_id,
|
||||||
self.commit_repository)
|
self.commit_repository)
|
||||||
|
|
||||||
@@ -1184,7 +1132,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Adds a Note to the database, assigning internal IDs if they have
|
Adds a Note to the database, assigning internal IDs if they have
|
||||||
not already been defined.
|
not already been defined.
|
||||||
"""
|
"""
|
||||||
return self._add_object(obj, transaction,
|
return self.__add_object(obj, transaction,
|
||||||
self.find_next_note_gramps_id,
|
self.find_next_note_gramps_id,
|
||||||
self.commit_note)
|
self.commit_note)
|
||||||
|
|
||||||
@@ -1258,7 +1206,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
return len(self.note_map)
|
return len(self.note_map)
|
||||||
|
|
||||||
def _all_handles(self, table):
|
def __all_handles(self, table):
|
||||||
return table.keys()
|
return table.keys()
|
||||||
|
|
||||||
def get_person_handles(self, sort_handles=True):
|
def get_person_handles(self, sort_handles=True):
|
||||||
@@ -1278,7 +1226,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
slist.sort()
|
slist.sort()
|
||||||
return map(lambda x: x[1], slist)
|
return map(lambda x: x[1], slist)
|
||||||
else:
|
else:
|
||||||
return self._all_handles(self.person_map)
|
return self.__all_handles(self.person_map)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_place_handles(self, sort_handles=True):
|
def get_place_handles(self, sort_handles=True):
|
||||||
@@ -1300,7 +1248,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
val = map(lambda x: x[1], slist)
|
val = map(lambda x: x[1], slist)
|
||||||
return val
|
return val
|
||||||
else:
|
else:
|
||||||
return self._all_handles(self.place_map)
|
return self.__all_handles(self.place_map)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_source_handles(self, sort_handles=True):
|
def get_source_handles(self, sort_handles=True):
|
||||||
@@ -1310,9 +1258,9 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Source title.
|
Source title.
|
||||||
"""
|
"""
|
||||||
if self.db_is_open:
|
if self.db_is_open:
|
||||||
handle_list = self._all_handles(self.source_map)
|
handle_list = self.__all_handles(self.source_map)
|
||||||
if sort_handles:
|
if sort_handles:
|
||||||
handle_list.sort(self._sortbysource)
|
handle_list.sort(self.__sortbysource)
|
||||||
return handle_list
|
return handle_list
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -1322,9 +1270,9 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
the database. If sort_handles is True, the list is sorted by title.
|
the database. If sort_handles is True, the list is sorted by title.
|
||||||
"""
|
"""
|
||||||
if self.db_is_open:
|
if self.db_is_open:
|
||||||
handle_list = self._all_handles(self.media_map)
|
handle_list = self.__all_handles(self.media_map)
|
||||||
if sort_handles:
|
if sort_handles:
|
||||||
handle_list.sort(self._sortbymedia)
|
handle_list.sort(self.__sortbymedia)
|
||||||
return handle_list
|
return handle_list
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -1334,7 +1282,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
the database.
|
the database.
|
||||||
"""
|
"""
|
||||||
if self.db_is_open:
|
if self.db_is_open:
|
||||||
return self._all_handles(self.event_map)
|
return self.__all_handles(self.event_map)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_family_handles(self):
|
def get_family_handles(self):
|
||||||
@@ -1343,7 +1291,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
the database.
|
the database.
|
||||||
"""
|
"""
|
||||||
if self.db_is_open:
|
if self.db_is_open:
|
||||||
return self._all_handles(self.family_map)
|
return self.__all_handles(self.family_map)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_repository_handles(self):
|
def get_repository_handles(self):
|
||||||
@@ -1352,7 +1300,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
the database.
|
the database.
|
||||||
"""
|
"""
|
||||||
if self.db_is_open:
|
if self.db_is_open:
|
||||||
return self._all_handles(self.repository_map)
|
return self.__all_handles(self.repository_map)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_note_handles(self):
|
def get_note_handles(self):
|
||||||
@@ -1361,7 +1309,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
the database.
|
the database.
|
||||||
"""
|
"""
|
||||||
if self.db_is_open:
|
if self.db_is_open:
|
||||||
return self._all_handles(self.note_map)
|
return self.__all_handles(self.note_map)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_gramps_ids(self, obj_key):
|
def get_gramps_ids(self, obj_key):
|
||||||
@@ -1497,7 +1445,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
transaction_commit function of the this database object.
|
transaction_commit function of the this database object.
|
||||||
"""
|
"""
|
||||||
if self.__LOG_ALL:
|
if self.__LOG_ALL:
|
||||||
log.debug("%s: Transaction begin '%s'\n"
|
LOG.debug("%s: Transaction begin '%s'\n"
|
||||||
% (self.__class__.__name__, str(msg)))
|
% (self.__class__.__name__, str(msg)))
|
||||||
if batch:
|
if batch:
|
||||||
# A batch transaction does not store the commits
|
# A batch transaction does not store the commits
|
||||||
@@ -1514,7 +1462,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Commits the transaction to the assocated UNDO database.
|
Commits the transaction to the assocated UNDO database.
|
||||||
"""
|
"""
|
||||||
if self.__LOG_ALL:
|
if self.__LOG_ALL:
|
||||||
log.debug("%s: Transaction commit '%s'\n"
|
LOG.debug("%s: Transaction commit '%s'\n"
|
||||||
% (self.__class__.__name__, str(msg)))
|
% (self.__class__.__name__, str(msg)))
|
||||||
|
|
||||||
if not len(transaction) or self.readonly:
|
if not len(transaction) or self.readonly:
|
||||||
@@ -1536,51 +1484,44 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
for index in range(self.undoindex+1, _UNDO_SIZE):
|
for index in range(self.undoindex+1, _UNDO_SIZE):
|
||||||
self.translist[index] = None
|
self.translist[index] = None
|
||||||
|
|
||||||
person_add = self._do_commit(transaction.person_add,self.person_map)
|
person_add = self.__do_commit(transaction.person_add, self.person_map)
|
||||||
family_add = self._do_commit(transaction.family_add,self.family_map)
|
family_add = self.__do_commit(transaction.family_add, self.family_map)
|
||||||
source_add = self._do_commit(transaction.source_add,self.source_map)
|
source_add = self.__do_commit(transaction.source_add, self.source_map)
|
||||||
place_add = self._do_commit(transaction.place_add, self.place_map)
|
place_add = self.__do_commit(transaction.place_add, self.place_map)
|
||||||
media_add = self._do_commit(transaction.media_add, self.media_map)
|
media_add = self.__do_commit(transaction.media_add, self.media_map)
|
||||||
event_add = self._do_commit(transaction.event_add, self.event_map)
|
event_add = self.__do_commit(transaction.event_add, self.event_map)
|
||||||
repository_add= self._do_commit(transaction.repository_add,
|
repository_add = self.__do_commit(transaction.repository_add,
|
||||||
self.repository_map)
|
self.repository_map)
|
||||||
note_add = self._do_commit(transaction.note_add, self.note_map)
|
|
||||||
|
|
||||||
person_upd = self._do_commit(transaction.person_update,
|
note_add = self.__do_commit(transaction.note_add, self.note_map)
|
||||||
self.person_map)
|
person_upd = self.__do_commit(transaction.person_update, self.person_map)
|
||||||
family_upd = self._do_commit(transaction.family_update,
|
family_upd = self.__do_commit(transaction.family_update, self.family_map)
|
||||||
self.family_map)
|
source_upd = self.__do_commit(transaction.source_update, self.source_map)
|
||||||
source_upd = self._do_commit(transaction.source_update,
|
place_upd = self.__do_commit(transaction.place_update, self.place_map)
|
||||||
self.source_map)
|
media_upd = self.__do_commit(transaction.media_update, self.media_map)
|
||||||
place_upd = self._do_commit(transaction.place_update,
|
event_upd = self.__do_commit(transaction.event_update, self.event_map)
|
||||||
self.place_map)
|
repository_upd = self.__do_commit(transaction.repository_update,
|
||||||
media_upd = self._do_commit(transaction.media_update,
|
|
||||||
self.media_map)
|
|
||||||
event_upd = self._do_commit(transaction.event_update,
|
|
||||||
self.event_map)
|
|
||||||
repository_upd= self._do_commit(transaction.repository_update,
|
|
||||||
self.repository_map)
|
self.repository_map)
|
||||||
note_upd = self._do_commit(transaction.note_update,
|
note_upd = self.__do_commit(transaction.note_update, self.note_map)
|
||||||
self.note_map)
|
|
||||||
|
|
||||||
self._do_emit('person', person_add, person_upd, transaction.person_del)
|
self.__do_emit('person', person_add, person_upd, transaction.person_del)
|
||||||
self._do_emit('family', family_add, family_upd, transaction.family_del)
|
self.__do_emit('family', family_add, family_upd, transaction.family_del)
|
||||||
self._do_emit('event', event_add, event_upd, transaction.event_del)
|
self.__do_emit('event', event_add, event_upd, transaction.event_del)
|
||||||
self._do_emit('source', source_add, source_upd, transaction.source_del)
|
self.__do_emit('source', source_add, source_upd, transaction.source_del)
|
||||||
self._do_emit('place', place_add, place_upd, transaction.place_del)
|
self.__do_emit('place', place_add, place_upd, transaction.place_del)
|
||||||
self._do_emit('media', media_add, media_upd, transaction.media_del)
|
self.__do_emit('media', media_add, media_upd, transaction.media_del)
|
||||||
self._do_emit('repository', repository_add, repository_upd,
|
self.__do_emit('repository', repository_add, repository_upd,
|
||||||
transaction.repository_del)
|
transaction.repository_del)
|
||||||
self._do_emit('note', note_add, note_upd, transaction.note_del)
|
self.__do_emit('note', note_add, note_upd, transaction.note_del)
|
||||||
|
|
||||||
self._do_del(transaction.person_del, self._del_person)
|
self.__do_del(transaction.person_del, self.__del_person)
|
||||||
self._do_del(transaction.family_del, self._del_family)
|
self.__do_del(transaction.family_del, self.__del_family)
|
||||||
self._do_del(transaction.place_del, self._del_place)
|
self.__do_del(transaction.place_del, self.__del_place)
|
||||||
self._do_del(transaction.source_del, self._del_source)
|
self.__do_del(transaction.source_del, self.__del_source)
|
||||||
self._do_del(transaction.event_del, self._del_event)
|
self.__do_del(transaction.event_del, self.__del_event)
|
||||||
self._do_del(transaction.media_del, self._del_media)
|
self.__do_del(transaction.media_del, self.__del_media)
|
||||||
self._do_del(transaction.repository_del, self._del_repository)
|
self.__do_del(transaction.repository_del, self.__del_repository)
|
||||||
self._do_del(transaction.note_del, self._del_note)
|
self.__do_del(transaction.note_del, self.__del_note)
|
||||||
|
|
||||||
if self.undo_callback:
|
if self.undo_callback:
|
||||||
self.undo_callback(_("_Undo %s") % transaction.get_description())
|
self.undo_callback(_("_Undo %s") % transaction.get_description())
|
||||||
@@ -1589,7 +1530,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
if self.undo_history_callback:
|
if self.undo_history_callback:
|
||||||
self.undo_history_callback()
|
self.undo_history_callback()
|
||||||
|
|
||||||
def _do_emit(self, objtype, add_list, upd_list, del_list):
|
def __do_emit(self, objtype, add_list, upd_list, del_list):
|
||||||
if add_list:
|
if add_list:
|
||||||
self.emit(objtype + '-add', (add_list, ))
|
self.emit(objtype + '-add', (add_list, ))
|
||||||
if upd_list:
|
if upd_list:
|
||||||
@@ -1597,12 +1538,12 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
if del_list:
|
if del_list:
|
||||||
self.emit(objtype + '-delete', (del_list, ))
|
self.emit(objtype + '-delete', (del_list, ))
|
||||||
|
|
||||||
def _do_del(self, del_list, func):
|
def __do_del(self, del_list, func):
|
||||||
for handle in del_list:
|
for handle in del_list:
|
||||||
func(handle)
|
func(handle)
|
||||||
return del_list
|
return del_list
|
||||||
|
|
||||||
def _do_commit(self, add_list, db_map):
|
def __do_commit(self, add_list, db_map):
|
||||||
retlist = []
|
retlist = []
|
||||||
for (handle, data) in add_list:
|
for (handle, data) in add_list:
|
||||||
db_map[handle] = data
|
db_map[handle] = data
|
||||||
@@ -1610,14 +1551,17 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
return retlist
|
return retlist
|
||||||
|
|
||||||
def undo_available(self):
|
def undo_available(self):
|
||||||
# returns boolean of whether or not there's a possibility of undo
|
"""
|
||||||
|
returns boolean of whether or not there's a possibility of undo
|
||||||
|
"""
|
||||||
if self.undoindex == -1 or self.readonly:
|
if self.undoindex == -1 or self.readonly:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def redo_available(self):
|
def redo_available(self):
|
||||||
# returns boolean of whether or not there's a possibility of redo
|
"""
|
||||||
|
returns boolean of whether or not there's a possibility of redo
|
||||||
|
"""
|
||||||
if self.undoindex >= _UNDO_SIZE or self.readonly:
|
if self.undoindex >= _UNDO_SIZE or self.readonly:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -1648,7 +1592,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
if key == REFERENCE_KEY:
|
if key == REFERENCE_KEY:
|
||||||
self.undo_reference(old_data, handle)
|
self.undo_reference(old_data, handle)
|
||||||
else:
|
else:
|
||||||
self.undo_data(old_data, handle, mapbase[key], _sigbase[key])
|
self.undo_data(old_data, handle, mapbase[key], __SIGBASE[key])
|
||||||
|
|
||||||
if self.undo_callback:
|
if self.undo_callback:
|
||||||
if self.undo_available():
|
if self.undo_available():
|
||||||
@@ -1690,7 +1634,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
if key == REFERENCE_KEY:
|
if key == REFERENCE_KEY:
|
||||||
self.undo_reference(new_data, handle)
|
self.undo_reference(new_data, handle)
|
||||||
else:
|
else:
|
||||||
self.undo_data(new_data, handle, mapbase[key], _sigbase[key])
|
self.undo_data(new_data, handle, mapbase[key], __SIGBASE[key])
|
||||||
|
|
||||||
if self.undo_callback:
|
if self.undo_callback:
|
||||||
if self.undo_available():
|
if self.undo_available():
|
||||||
@@ -1926,35 +1870,35 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
|
|
||||||
if self.readonly or not handle:
|
if self.readonly or not handle:
|
||||||
return
|
return
|
||||||
self._delete_primary_from_reference_map(handle, transaction)
|
self.__delete_primary_from_reference_map(handle, transaction)
|
||||||
person = self.get_person_from_handle(handle)
|
person = self.get_person_from_handle(handle)
|
||||||
self.genderStats.uncount_person (person)
|
self.genderStats.uncount_person (person)
|
||||||
self.remove_from_surname_list(person)
|
self.remove_from_surname_list(person)
|
||||||
if transaction.batch:
|
if transaction.batch:
|
||||||
self._del_person(handle)
|
self.__del_person(handle)
|
||||||
else:
|
else:
|
||||||
transaction.add(PERSON_KEY, handle, person.serialize(), None)
|
transaction.add(PERSON_KEY, handle, person.serialize(), None)
|
||||||
transaction.person_del.append(str(handle))
|
transaction.person_del.append(str(handle))
|
||||||
|
|
||||||
def get_del_func(self, key):
|
def get_del_func(self, key):
|
||||||
key2del = {
|
key2del = {
|
||||||
PERSON_KEY: self._del_person,
|
PERSON_KEY: self.__del_person,
|
||||||
FAMILY_KEY: self._del_family,
|
FAMILY_KEY: self.__del_family,
|
||||||
SOURCE_KEY: self._del_source,
|
SOURCE_KEY: self.__del_source,
|
||||||
EVENT_KEY: self._del_event,
|
EVENT_KEY: self.__del_event,
|
||||||
MEDIA_KEY: self._del_media,
|
MEDIA_KEY: self.__del_media,
|
||||||
PLACE_KEY: self._del_place,
|
PLACE_KEY: self.__del_place,
|
||||||
REPOSITORY_KEY: self._del_repository,
|
REPOSITORY_KEY: self.__del_repository,
|
||||||
NOTE_KEY: self._del_note,
|
NOTE_KEY: self.__del_note,
|
||||||
}
|
}
|
||||||
return key2del[key]
|
return key2del[key]
|
||||||
|
|
||||||
def _do_remove_object(self, handle, trans, dmap, key, del_list):
|
def __do_remove_object(self, handle, trans, dmap, key, del_list):
|
||||||
if self.readonly or not handle:
|
if self.readonly or not handle:
|
||||||
return
|
return
|
||||||
|
|
||||||
handle = str(handle)
|
handle = str(handle)
|
||||||
self._delete_primary_from_reference_map(handle, trans)
|
self.__delete_primary_from_reference_map(handle, trans)
|
||||||
if trans.batch:
|
if trans.batch:
|
||||||
del_func = self.get_del_func(key)
|
del_func = self.get_del_func(key)
|
||||||
del_func(handle)
|
del_func(handle)
|
||||||
@@ -1969,7 +1913,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database, preserving the change in the passed transaction. This
|
database, preserving the change in the passed transaction. This
|
||||||
method must be overridden in the derived class.
|
method must be overridden in the derived class.
|
||||||
"""
|
"""
|
||||||
self._do_remove_object(handle, transaction, self.source_map,
|
self.__do_remove_object(handle, transaction, self.source_map,
|
||||||
SOURCE_KEY, transaction.source_del)
|
SOURCE_KEY, transaction.source_del)
|
||||||
|
|
||||||
def remove_event(self, handle, transaction):
|
def remove_event(self, handle, transaction):
|
||||||
@@ -1978,7 +1922,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database, preserving the change in the passed transaction. This
|
database, preserving the change in the passed transaction. This
|
||||||
method must be overridden in the derived class.
|
method must be overridden in the derived class.
|
||||||
"""
|
"""
|
||||||
self._do_remove_object(handle, transaction, self.event_map,
|
self.__do_remove_object(handle, transaction, self.event_map,
|
||||||
EVENT_KEY, transaction.event_del)
|
EVENT_KEY, transaction.event_del)
|
||||||
|
|
||||||
def remove_object(self, handle, transaction):
|
def remove_object(self, handle, transaction):
|
||||||
@@ -1987,7 +1931,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database, preserving the change in the passed transaction. This
|
database, preserving the change in the passed transaction. This
|
||||||
method must be overridden in the derived class.
|
method must be overridden in the derived class.
|
||||||
"""
|
"""
|
||||||
self._do_remove_object(handle, transaction, self.media_map,
|
self.__do_remove_object(handle, transaction, self.media_map,
|
||||||
MEDIA_KEY, transaction.media_del)
|
MEDIA_KEY, transaction.media_del)
|
||||||
|
|
||||||
def remove_place(self, handle, transaction):
|
def remove_place(self, handle, transaction):
|
||||||
@@ -1996,7 +1940,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database, preserving the change in the passed transaction. This
|
database, preserving the change in the passed transaction. This
|
||||||
method must be overridden in the derived class.
|
method must be overridden in the derived class.
|
||||||
"""
|
"""
|
||||||
self._do_remove_object(handle, transaction, self.place_map,
|
self.__do_remove_object(handle, transaction, self.place_map,
|
||||||
PLACE_KEY, transaction.place_del)
|
PLACE_KEY, transaction.place_del)
|
||||||
|
|
||||||
def remove_family(self, handle, transaction):
|
def remove_family(self, handle, transaction):
|
||||||
@@ -2005,7 +1949,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database, preserving the change in the passed transaction. This
|
database, preserving the change in the passed transaction. This
|
||||||
method must be overridden in the derived class.
|
method must be overridden in the derived class.
|
||||||
"""
|
"""
|
||||||
self._do_remove_object(handle, transaction, self.family_map,
|
self.__do_remove_object(handle, transaction, self.family_map,
|
||||||
FAMILY_KEY, transaction.family_del)
|
FAMILY_KEY, transaction.family_del)
|
||||||
|
|
||||||
def remove_repository(self, handle, transaction):
|
def remove_repository(self, handle, transaction):
|
||||||
@@ -2014,7 +1958,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database, preserving the change in the passed transaction. This
|
database, preserving the change in the passed transaction. This
|
||||||
method must be overridden in the derived class.
|
method must be overridden in the derived class.
|
||||||
"""
|
"""
|
||||||
self._do_remove_object(handle, transaction, self.repository_map,
|
self.__do_remove_object(handle, transaction, self.repository_map,
|
||||||
REPOSITORY_KEY, transaction.repository_del)
|
REPOSITORY_KEY, transaction.repository_del)
|
||||||
|
|
||||||
def remove_note(self, handle, transaction):
|
def remove_note(self, handle, transaction):
|
||||||
@@ -2023,7 +1967,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database, preserving the change in the passed transaction. This
|
database, preserving the change in the passed transaction. This
|
||||||
method must be overridden in the derived class.
|
method must be overridden in the derived class.
|
||||||
"""
|
"""
|
||||||
self._do_remove_object(handle, transaction, self.note_map,
|
self.__do_remove_object(handle, transaction, self.note_map,
|
||||||
NOTE_KEY, transaction.note_del)
|
NOTE_KEY, transaction.note_del)
|
||||||
|
|
||||||
def get_raw_person_data(self, handle):
|
def get_raw_person_data(self, handle):
|
||||||
@@ -2098,21 +2042,21 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
return self.note_map.has_key(str(handle))
|
return self.note_map.has_key(str(handle))
|
||||||
|
|
||||||
def _sortbyplace(self, first, second):
|
def __sortbyplace(self, first, second):
|
||||||
return locale.strcoll(self.place_map.get(str(first))[2],
|
return locale.strcoll(self.place_map.get(str(first))[2],
|
||||||
self.place_map.get(str(second))[2])
|
self.place_map.get(str(second))[2])
|
||||||
|
|
||||||
def _sortbysource(self, first, second):
|
def __sortbysource(self, first, second):
|
||||||
source1 = unicode(self.source_map[str(first)][2])
|
source1 = unicode(self.source_map[str(first)][2])
|
||||||
source2 = unicode(self.source_map[str(second)][2])
|
source2 = unicode(self.source_map[str(second)][2])
|
||||||
return locale.strcoll(source1, source2)
|
return locale.strcoll(source1, source2)
|
||||||
|
|
||||||
def _sortbymedia(self, first, second):
|
def __sortbymedia(self, first, second):
|
||||||
media1 = self.media_map[str(first)][4]
|
media1 = self.media_map[str(first)][4]
|
||||||
media2 = self.media_map[str(second)][4]
|
media2 = self.media_map[str(second)][4]
|
||||||
return locale.strcoll(media1, media2)
|
return locale.strcoll(media1, media2)
|
||||||
|
|
||||||
def _set_column_order(self, col_list, name):
|
def __set_column_order(self, col_list, name):
|
||||||
if (self.metadata != None) and (not self.readonly):
|
if (self.metadata != None) and (not self.readonly):
|
||||||
self.metadata[name] = col_list
|
self.metadata[name] = col_list
|
||||||
|
|
||||||
@@ -2121,65 +2065,65 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
Stores the Person display common information in the
|
Stores the Person display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, PERSON_COL_KEY)
|
self.__set_column_order(col_list, PERSON_COL_KEY)
|
||||||
|
|
||||||
def set_family_list_column_order(self, col_list):
|
def set_family_list_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Person display common information in the
|
Stores the Person display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, FAMILY_COL_KEY)
|
self.__set_column_order(col_list, FAMILY_COL_KEY)
|
||||||
|
|
||||||
def set_child_column_order(self, col_list):
|
def set_child_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Person display common information in the
|
Stores the Person display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, CHILD_COL_KEY)
|
self.__set_column_order(col_list, CHILD_COL_KEY)
|
||||||
|
|
||||||
def set_place_column_order(self, col_list):
|
def set_place_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Place display common information in the
|
Stores the Place display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, PLACE_COL_KEY)
|
self.__set_column_order(col_list, PLACE_COL_KEY)
|
||||||
|
|
||||||
def set_source_column_order(self, col_list):
|
def set_source_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Source display common information in the
|
Stores the Source display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, SOURCE_COL_KEY)
|
self.__set_column_order(col_list, SOURCE_COL_KEY)
|
||||||
|
|
||||||
def set_media_column_order(self, col_list):
|
def set_media_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Media display common information in the
|
Stores the Media display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, MEDIA_COL_KEY)
|
self.__set_column_order(col_list, MEDIA_COL_KEY)
|
||||||
|
|
||||||
def set_event_column_order(self, col_list):
|
def set_event_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Event display common information in the
|
Stores the Event display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, EVENT_COL_KEY)
|
self.__set_column_order(col_list, EVENT_COL_KEY)
|
||||||
|
|
||||||
def set_repository_column_order(self, col_list):
|
def set_repository_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Repository display common information in the
|
Stores the Repository display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, REPOSITORY_COL_KEY)
|
self.__set_column_order(col_list, REPOSITORY_COL_KEY)
|
||||||
|
|
||||||
def set_note_column_order(self, col_list):
|
def set_note_column_order(self, col_list):
|
||||||
"""
|
"""
|
||||||
Stores the Note display common information in the
|
Stores the Note display common information in the
|
||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
self._set_column_order(col_list, NOTE_COL_KEY)
|
self.__set_column_order(col_list, NOTE_COL_KEY)
|
||||||
|
|
||||||
def _get_column_order(self, name, default):
|
def __get_column_order(self, name, default):
|
||||||
if self.metadata == None:
|
if self.metadata == None:
|
||||||
return default
|
return default
|
||||||
else:
|
else:
|
||||||
@@ -2197,10 +2141,10 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
default = [(1, 1, 100), (1, 2, 100), (1, 3, 150), (0, 4, 150),
|
default = [(1, 1, 100), (1, 2, 100), (1, 3, 150), (0, 4, 150),
|
||||||
(1, 5, 150), (0, 6, 150), (0, 7, 100), (0, 8, 100),
|
(1, 5, 150), (0, 6, 150), (0, 7, 100), (0, 8, 100),
|
||||||
]
|
]
|
||||||
return self._get_column_order(PERSON_COL_KEY, default)
|
return self.__get_column_order(PERSON_COL_KEY, default)
|
||||||
|
|
||||||
def _get_columns(self, key, default):
|
def __get_columns(self, key, default):
|
||||||
values = self._get_column_order(key, default)
|
values = self.__get_column_order(key, default)
|
||||||
new = []
|
new = []
|
||||||
for val in values:
|
for val in values:
|
||||||
if len(val) == 2:
|
if len(val) == 2:
|
||||||
@@ -2219,7 +2163,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
default = [(1, 0, 75), (1, 1, 200), (1, 2, 200), (1, 3, 100),
|
default = [(1, 0, 75), (1, 1, 200), (1, 2, 200), (1, 3, 100),
|
||||||
(0, 4, 100)]
|
(0, 4, 100)]
|
||||||
return self._get_columns(FAMILY_COL_KEY, default)
|
return self.__get_columns(FAMILY_COL_KEY, default)
|
||||||
|
|
||||||
def get_child_column_order(self):
|
def get_child_column_order(self):
|
||||||
"""
|
"""
|
||||||
@@ -2228,7 +2172,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
default = [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
|
default = [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
|
||||||
(0, 6), (0, 7)]
|
(0, 6), (0, 7)]
|
||||||
return self._get_column_order(CHILD_COL_KEY, default)
|
return self.__get_column_order(CHILD_COL_KEY, default)
|
||||||
|
|
||||||
def get_place_column_order(self):
|
def get_place_column_order(self):
|
||||||
"""
|
"""
|
||||||
@@ -2238,7 +2182,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
default = [(1, 0, 250), (1, 1, 75), (1, 11, 100), (0, 3, 100),
|
default = [(1, 0, 250), (1, 1, 75), (1, 11, 100), (0, 3, 100),
|
||||||
(1, 4, 100, ), (0, 5, 150), (1, 6, 150), (0, 7, 150),
|
(1, 4, 100, ), (0, 5, 150), (1, 6, 150), (0, 7, 150),
|
||||||
(0, 8, 150), (0, 9, 150), (0, 10, 150),(0,2,100)]
|
(0, 8, 150), (0, 9, 150), (0, 10, 150),(0,2,100)]
|
||||||
return self._get_columns(PLACE_COL_KEY, default)
|
return self.__get_columns(PLACE_COL_KEY, default)
|
||||||
|
|
||||||
def get_source_column_order(self):
|
def get_source_column_order(self):
|
||||||
"""
|
"""
|
||||||
@@ -2247,7 +2191,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
default = [(1, 0, 200), (1, 1, 75), (1, 2, 150), (0, 3, 100),
|
default = [(1, 0, 200), (1, 1, 75), (1, 2, 150), (0, 3, 100),
|
||||||
(1, 4, 150), (0, 5, 100)]
|
(1, 4, 150), (0, 5, 100)]
|
||||||
return self._get_columns(SOURCE_COL_KEY, default)
|
return self.__get_columns(SOURCE_COL_KEY, default)
|
||||||
|
|
||||||
def get_media_column_order(self):
|
def get_media_column_order(self):
|
||||||
"""
|
"""
|
||||||
@@ -2256,7 +2200,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
default = [(1, 0, 200, ), (1, 1, 75), (1, 2, 100), (1, 3, 200),
|
default = [(1, 0, 200, ), (1, 1, 75), (1, 2, 100), (1, 3, 200),
|
||||||
(1, 5, 150), (0, 4, 150)]
|
(1, 5, 150), (0, 4, 150)]
|
||||||
return self._get_columns(MEDIA_COL_KEY, default)
|
return self.__get_columns(MEDIA_COL_KEY, default)
|
||||||
|
|
||||||
def get_event_column_order(self):
|
def get_event_column_order(self):
|
||||||
"""
|
"""
|
||||||
@@ -2265,7 +2209,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
"""
|
"""
|
||||||
default = [(1, 0, 200), (1, 1, 75), (1, 2, 100), (1, 3, 150),
|
default = [(1, 0, 200), (1, 1, 75), (1, 2, 100), (1, 3, 150),
|
||||||
(1, 4, 200), (0, 5, 100)]
|
(1, 4, 200), (0, 5, 100)]
|
||||||
return self._get_columns(EVENT_COL_KEY, default)
|
return self.__get_columns(EVENT_COL_KEY, default)
|
||||||
|
|
||||||
def get_repository_column_order(self):
|
def get_repository_column_order(self):
|
||||||
"""
|
"""
|
||||||
@@ -2275,7 +2219,7 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
default = [(1, 0, 200), (1, 1, 75), (0, 5, 100), (0, 6, 100),
|
default = [(1, 0, 200), (1, 1, 75), (0, 5, 100), (0, 6, 100),
|
||||||
(1, 2, 100), (1, 3, 250), (1, 4, 100), (0, 7, 100),
|
(1, 2, 100), (1, 3, 250), (1, 4, 100), (0, 7, 100),
|
||||||
(0, 8, 100), (0, 9, 100), (0, 10, 100)]
|
(0, 8, 100), (0, 9, 100), (0, 10, 100)]
|
||||||
return self._get_columns(REPOSITORY_COL_KEY, default)
|
return self.__get_columns(REPOSITORY_COL_KEY, default)
|
||||||
|
|
||||||
def get_note_column_order(self):
|
def get_note_column_order(self):
|
||||||
"""
|
"""
|
||||||
@@ -2283,15 +2227,15 @@ class GrampsDbBase(GrampsDBCallback):
|
|||||||
database's metadata.
|
database's metadata.
|
||||||
"""
|
"""
|
||||||
default = [(1, 0, 100), (1, 1, 100), (0, 2, 100), (1, 3, 100)]
|
default = [(1, 0, 100), (1, 1, 100), (0, 2, 100), (1, 3, 100)]
|
||||||
return self._get_columns(NOTE_COL_KEY, default)
|
return self.__get_columns(NOTE_COL_KEY, default)
|
||||||
|
|
||||||
def _delete_primary_from_reference_map(self, handle, transaction):
|
def __delete_primary_from_reference_map(self, handle, transaction):
|
||||||
"""Called each time an object is removed from the database. This can
|
"""Called each time an object is removed from the database. This can
|
||||||
be used by subclasses to update any additional index tables that might
|
be used by subclasses to update any additional index tables that might
|
||||||
need to be changed."""
|
need to be changed."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _update_reference_map(self, obj, transaction):
|
def __update_reference_map(self, obj, transaction):
|
||||||
"""Called each time an object is writen to the database. This can
|
"""Called each time an object is writen to the database. This can
|
||||||
be used by subclasses to update any additional index tables that might
|
be used by subclasses to update any additional index tables that might
|
||||||
need to be changed."""
|
need to be changed."""
|
||||||
@@ -2444,12 +2388,6 @@ class Transaction:
|
|||||||
self.note_del = []
|
self.note_del = []
|
||||||
self.note_update = []
|
self.note_update = []
|
||||||
|
|
||||||
## def set_batch(self, batch):
|
|
||||||
## self.batch = batch
|
|
||||||
|
|
||||||
def get_batch(self):
|
|
||||||
return self.batch
|
|
||||||
|
|
||||||
def get_description(self):
|
def get_description(self):
|
||||||
"""
|
"""
|
||||||
Returns the text string that describes the logical operation
|
Returns the text string that describes the logical operation
|
||||||
|
@@ -39,6 +39,7 @@ import time
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from RelLib import *
|
from RelLib import *
|
||||||
from _GrampsDbBase import *
|
from _GrampsDbBase import *
|
||||||
|
from _GrampsCursor import GrampsCursor
|
||||||
|
|
||||||
class GrampsInMemCursor(GrampsCursor):
|
class GrampsInMemCursor(GrampsCursor):
|
||||||
"""
|
"""
|
||||||
@@ -81,26 +82,7 @@ class GrampsInMemDB(GrampsDbBase):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""creates a new GrampsDB"""
|
"""creates a new GrampsDB"""
|
||||||
GrampsDbBase.__init__(self)
|
GrampsDbBase.__init__(self)
|
||||||
self.person_map = {}
|
|
||||||
self.name_group = {}
|
|
||||||
self.family_map = {}
|
|
||||||
self.place_map = {}
|
|
||||||
self.source_map = {}
|
|
||||||
self.repository_map = {}
|
|
||||||
self.note_map = {}
|
|
||||||
self.media_map = {}
|
|
||||||
self.event_map = {}
|
|
||||||
self.metadata = {}
|
|
||||||
self.filename = ""
|
self.filename = ""
|
||||||
self.id_trans = {}
|
|
||||||
self.pid_trans = {}
|
|
||||||
self.fid_trans = {}
|
|
||||||
self.eid_trans = {}
|
|
||||||
self.sid_trans = {}
|
|
||||||
self.rid_trans = {}
|
|
||||||
self.nid_trans = {}
|
|
||||||
self.oid_trans = {}
|
|
||||||
self.undodb = []
|
|
||||||
|
|
||||||
def load(self,name,callback,mode="w"):
|
def load(self,name,callback,mode="w"):
|
||||||
self.full_name = name
|
self.full_name = name
|
||||||
@@ -181,42 +163,42 @@ class GrampsInMemDB(GrampsDbBase):
|
|||||||
if do_remove:
|
if do_remove:
|
||||||
self.surname_list.remove(unicode(name))
|
self.surname_list.remove(unicode(name))
|
||||||
|
|
||||||
def _del_person(self,handle):
|
def __del_person(self,handle):
|
||||||
person = self.get_person_from_handle(str(handle))
|
person = self.get_person_from_handle(str(handle))
|
||||||
del self.id_trans[person.get_gramps_id()]
|
del self.id_trans[person.get_gramps_id()]
|
||||||
del self.person_map[str(handle)]
|
del self.person_map[str(handle)]
|
||||||
|
|
||||||
def _del_source(self,handle):
|
def __del_source(self,handle):
|
||||||
source = self.get_source_from_handle(str(handle))
|
source = self.get_source_from_handle(str(handle))
|
||||||
del self.sid_trans[source.get_gramps_id()]
|
del self.sid_trans[source.get_gramps_id()]
|
||||||
del self.source_map[str(handle)]
|
del self.source_map[str(handle)]
|
||||||
|
|
||||||
def _del_repository(self,handle):
|
def __del_repository(self,handle):
|
||||||
repository = self.get_repository_from_handle(str(handle))
|
repository = self.get_repository_from_handle(str(handle))
|
||||||
del self.rid_trans[repository.get_gramps_id()]
|
del self.rid_trans[repository.get_gramps_id()]
|
||||||
del self.repository_map[str(handle)]
|
del self.repository_map[str(handle)]
|
||||||
|
|
||||||
def _del_note(self,handle):
|
def __del_note(self,handle):
|
||||||
note = self.get_note_from_handle(str(handle))
|
note = self.get_note_from_handle(str(handle))
|
||||||
del self.nid_trans[note.get_gramps_id()]
|
del self.nid_trans[note.get_gramps_id()]
|
||||||
del self.note_map[str(handle)]
|
del self.note_map[str(handle)]
|
||||||
|
|
||||||
def _del_place(self,handle):
|
def __del_place(self,handle):
|
||||||
place = self.get_place_from_handle(str(handle))
|
place = self.get_place_from_handle(str(handle))
|
||||||
del self.pid_trans[place.get_gramps_id()]
|
del self.pid_trans[place.get_gramps_id()]
|
||||||
del self.place_map[str(handle)]
|
del self.place_map[str(handle)]
|
||||||
|
|
||||||
def _del_media(self,handle):
|
def __del_media(self,handle):
|
||||||
obj = self.get_object_from_handle(str(handle))
|
obj = self.get_object_from_handle(str(handle))
|
||||||
del self.oid_trans[obj.get_gramps_id()]
|
del self.oid_trans[obj.get_gramps_id()]
|
||||||
del self.media_map[str(handle)]
|
del self.media_map[str(handle)]
|
||||||
|
|
||||||
def _del_family(self,handle):
|
def __del_family(self,handle):
|
||||||
family = self.get_family_from_handle(str(handle))
|
family = self.get_family_from_handle(str(handle))
|
||||||
del self.fid_trans[family.get_gramps_id()]
|
del self.fid_trans[family.get_gramps_id()]
|
||||||
del self.family_map[str(handle)]
|
del self.family_map[str(handle)]
|
||||||
|
|
||||||
def _del_event(self,handle):
|
def __del_event(self,handle):
|
||||||
event = self.get_event_from_handle(str(handle))
|
event = self.get_event_from_handle(str(handle))
|
||||||
del self.eid_trans[event.get_gramps_id()]
|
del self.eid_trans[event.get_gramps_id()]
|
||||||
del self.event_map[str(handle)]
|
del self.event_map[str(handle)]
|
||||||
@@ -263,7 +245,7 @@ class GrampsInMemDB(GrampsDbBase):
|
|||||||
trans_map[data[self.ID_INDEX]] = str(handle)
|
trans_map[data[self.ID_INDEX]] = str(handle)
|
||||||
self.emit(signal, ([handle], ))
|
self.emit(signal, ([handle], ))
|
||||||
|
|
||||||
def _commit_inmem_base(self,obj,db_map,trans_map):
|
def __commit_inmem_base(self,obj,db_map,trans_map):
|
||||||
if self.readonly or not obj or not obj.get_handle():
|
if self.readonly or not obj or not obj.get_handle():
|
||||||
return False
|
return False
|
||||||
gid = obj.gramps_id
|
gid = obj.gramps_id
|
||||||
@@ -276,43 +258,43 @@ class GrampsInMemDB(GrampsDbBase):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def commit_person(self,person,transaction,change_time=None):
|
def commit_person(self,person,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(person,self.person_map,self.id_trans):
|
if not self.__commit_inmem_base(person,self.person_map,self.id_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_person(self,person,transaction,change_time)
|
GrampsDbBase.commit_person(self,person,transaction,change_time)
|
||||||
|
|
||||||
def commit_place(self,place,transaction,change_time=None):
|
def commit_place(self,place,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(place,self.place_map,self.pid_trans):
|
if not self.__commit_inmem_base(place,self.place_map,self.pid_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_place(self,place,transaction,change_time)
|
GrampsDbBase.commit_place(self,place,transaction,change_time)
|
||||||
|
|
||||||
def commit_family(self,family,transaction,change_time=None):
|
def commit_family(self,family,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(family,self.family_map,self.fid_trans):
|
if not self.__commit_inmem_base(family,self.family_map,self.fid_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_family(self,family,transaction,change_time)
|
GrampsDbBase.commit_family(self,family,transaction,change_time)
|
||||||
|
|
||||||
def commit_event(self,event,transaction,change_time=None):
|
def commit_event(self,event,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(event,self.event_map,self.eid_trans):
|
if not self.__commit_inmem_base(event,self.event_map,self.eid_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_event(self,event,transaction,change_time)
|
GrampsDbBase.commit_event(self,event,transaction,change_time)
|
||||||
|
|
||||||
def commit_media_object(self,obj,transaction,change_time=None):
|
def commit_media_object(self,obj,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(obj,self.media_map,self.oid_trans):
|
if not self.__commit_inmem_base(obj,self.media_map,self.oid_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_media_object(self,obj,transaction,change_time)
|
GrampsDbBase.commit_media_object(self,obj,transaction,change_time)
|
||||||
|
|
||||||
def commit_source(self,source,transaction,change_time=None):
|
def commit_source(self,source,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(source,self.source_map,self.sid_trans):
|
if not self.__commit_inmem_base(source,self.source_map,self.sid_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_source(self,source,transaction,change_time)
|
GrampsDbBase.commit_source(self,source,transaction,change_time)
|
||||||
|
|
||||||
def commit_repository(self,repository,transaction,change_time=None):
|
def commit_repository(self,repository,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(repository,self.repository_map,
|
if not self.__commit_inmem_base(repository,self.repository_map,
|
||||||
self.rid_trans):
|
self.rid_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_repository(self,repository,transaction,change_time)
|
GrampsDbBase.commit_repository(self,repository,transaction,change_time)
|
||||||
|
|
||||||
def commit_note(self,note,transaction,change_time=None):
|
def commit_note(self,note,transaction,change_time=None):
|
||||||
if not self._commit_inmem_base(note, self.note_map,
|
if not self.__commit_inmem_base(note, self.note_map,
|
||||||
self.nid_trans):
|
self.nid_trans):
|
||||||
return
|
return
|
||||||
GrampsDbBase.commit_note(self,note,transaction,change_time)
|
GrampsDbBase.commit_note(self,note,transaction,change_time)
|
||||||
|
@@ -1,3 +1,23 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2007 Richard Taylor
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This module provides a progess dialog for displaying the status of
|
This module provides a progess dialog for displaying the status of
|
||||||
long running operations.
|
long running operations.
|
||||||
@@ -45,7 +65,7 @@ class ProgressMonitor(object):
|
|||||||
popup_time = None):
|
popup_time = None):
|
||||||
"""
|
"""
|
||||||
@param dialog_class: A class used to display the progress dialog.
|
@param dialog_class: A class used to display the progress dialog.
|
||||||
@type dialog_class: L{_GtkProgressDialog} or the same interface.
|
@type dialog_class: _GtkProgressDialog or the same interface.
|
||||||
|
|
||||||
@param dialog_class_params: A tuple that will be used as the initial
|
@param dialog_class_params: A tuple that will be used as the initial
|
||||||
arguments to the dialog_class, this might be used for passing in
|
arguments to the dialog_class, this might be used for passing in
|
||||||
|
@@ -84,7 +84,7 @@ gdir_PYTHON = \
|
|||||||
MOSTLYCLEANFILES = *pyc *pyo
|
MOSTLYCLEANFILES = *pyc *pyo
|
||||||
|
|
||||||
# Which modules to document
|
# Which modules to document
|
||||||
docmodules = RelLib DateHandler GrampsDb Filters ReportBase GrampsDbUtils
|
docmodules = RelLib DateHandler GrampsDb Simple #Filters ReportBase GrampsDbUtils
|
||||||
|
|
||||||
pycheck:
|
pycheck:
|
||||||
for d in $(SUBDIRS) ; do \
|
for d in $(SUBDIRS) ; do \
|
||||||
@@ -93,8 +93,7 @@ pycheck:
|
|||||||
pychecker $(gdir_PYTHON)
|
pychecker $(gdir_PYTHON)
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
epydoc -o doc --url http://gramps-project.org --name GRAMPS --html $(docmodules)
|
epydoc -v -o html --html --exclude gtk --no-private --show-imports --url=http://gramps-project.org --graph=umlclasstree $(docmodules)
|
||||||
epydoc --pdf $(docmodules)
|
|
||||||
|
|
||||||
cmdplug:
|
cmdplug:
|
||||||
./build_cmdplug
|
./build_cmdplug
|
||||||
|
@@ -542,9 +542,6 @@ class SimpleAccess:
|
|||||||
|
|
||||||
@param obj: Person or Family
|
@param obj: Person or Family
|
||||||
@type obj: L{RelLib.Person} or L{RelLib.Family}
|
@type obj: L{RelLib.Person} or L{RelLib.Family}
|
||||||
@param restrict: Optional list of strings that will limit the types
|
|
||||||
of events to those of the specfied types.
|
|
||||||
@type restrict: list
|
|
||||||
@return: list of events assocated with the object
|
@return: list of events assocated with the object
|
||||||
@rtype: list
|
@rtype: list
|
||||||
"""
|
"""
|
||||||
|
31
src/Simple/__init__.py
Normal file
31
src/Simple/__init__.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2001 David R. Hampton
|
||||||
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
# $Id: __init__.py 7972 2007-01-24 19:45:57Z pez4brian $
|
||||||
|
|
||||||
|
"Simple access routines"
|
||||||
|
|
||||||
|
__author__ = "Donald N. Allingham"
|
||||||
|
__version__ = "$Revision: 7972 $"
|
||||||
|
|
||||||
|
from _SimpleAccess import *
|
||||||
|
from _SimpleDoc import *
|
||||||
|
|
Reference in New Issue
Block a user