GEPS008: Create new module for id utilities
svn: r19913
This commit is contained in:
parent
973f166c99
commit
541887e6ba
@ -213,6 +213,7 @@ src/gen/utils/callback.py
|
||||
src/gen/utils/callman.py
|
||||
src/gen/utils/cast.py
|
||||
src/gen/utils/file.py
|
||||
src/gen/utils/id.py
|
||||
src/gen/utils/image.py
|
||||
src/gen/utils/referent.py
|
||||
src/gen/utils/tree.py
|
||||
|
19
src/Utils.py
19
src/Utils.py
@ -217,25 +217,6 @@ from warnings import warn
|
||||
def set_titles(window, title, t, msg=None):
|
||||
warn('The Utils.set_titles is deprecated. Use ManagedWindow methods')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# create_id
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
rand = random.Random(time.time())
|
||||
|
||||
def create_id():
|
||||
return "%08x%08x" % ( int(time.time()*10000),
|
||||
rand.randint(0, sys.maxint))
|
||||
|
||||
def create_uid(self, handle=None):
|
||||
if handle:
|
||||
uid = uuid.uuid5(GRAMPS_UUID, handle)
|
||||
else:
|
||||
uid = uuid.uuid4()
|
||||
return uid.hex.upper()
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
@ -41,7 +41,7 @@ from gen.db import (PERSON_KEY,
|
||||
PLACE_KEY,
|
||||
REPOSITORY_KEY,
|
||||
NOTE_KEY)
|
||||
import Utils
|
||||
from gen.utils.id import create_id
|
||||
|
||||
class Cursor(object):
|
||||
"""
|
||||
@ -666,7 +666,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_person(self, person, trans, set_gid=True):
|
||||
if not person.handle:
|
||||
person.handle = Utils.create_id()
|
||||
person.handle = create_id()
|
||||
if not person.gramps_id or set_gid:
|
||||
person.gramps_id = self.find_next_person_gramps_id()
|
||||
self.commit_person(person, trans)
|
||||
@ -674,7 +674,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_family(self, family, trans, set_gid=True):
|
||||
if not family.handle:
|
||||
family.handle = Utils.create_id()
|
||||
family.handle = create_id()
|
||||
if not family.gramps_id or set_gid:
|
||||
family.gramps_id = self.find_next_family_gramps_id()
|
||||
self.commit_family(family, trans)
|
||||
@ -682,7 +682,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_citation(self, citation, trans, set_gid=True):
|
||||
if not citation.handle:
|
||||
citation.handle = Utils.create_id()
|
||||
citation.handle = create_id()
|
||||
if not citation.gramps_id or set_gid:
|
||||
citation.gramps_id = self.find_next_citation_gramps_id()
|
||||
self.commit_citation(citation, trans)
|
||||
@ -690,7 +690,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_source(self, source, trans, set_gid=True):
|
||||
if not source.handle:
|
||||
source.handle = Utils.create_id()
|
||||
source.handle = create_id()
|
||||
if not source.gramps_id or set_gid:
|
||||
source.gramps_id = self.find_next_source_gramps_id()
|
||||
self.commit_source(source, trans)
|
||||
@ -698,7 +698,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_repository(self, repository, trans, set_gid=True):
|
||||
if not repository.handle:
|
||||
repository.handle = Utils.create_id()
|
||||
repository.handle = create_id()
|
||||
if not repository.gramps_id or set_gid:
|
||||
repository.gramps_id = self.find_next_repository_gramps_id()
|
||||
self.commit_repository(repository, trans)
|
||||
@ -706,7 +706,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_note(self, note, trans, set_gid=True):
|
||||
if not note.handle:
|
||||
note.handle = Utils.create_id()
|
||||
note.handle = create_id()
|
||||
if not note.gramps_id or set_gid:
|
||||
note.gramps_id = self.find_next_note_gramps_id()
|
||||
self.commit_note(note, trans)
|
||||
@ -714,7 +714,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_place(self, place, trans, set_gid=True):
|
||||
if not place.handle:
|
||||
place.handle = Utils.create_id()
|
||||
place.handle = create_id()
|
||||
if not place.gramps_id or set_gid:
|
||||
place.gramps_id = self.find_next_place_gramps_id()
|
||||
self.commit_place(place, trans)
|
||||
@ -722,7 +722,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_event(self, event, trans, set_gid=True):
|
||||
if not event.handle:
|
||||
event.handle = Utils.create_id()
|
||||
event.handle = create_id()
|
||||
if not event.gramps_id or set_gid:
|
||||
event.gramps_id = self.find_next_event_gramps_id()
|
||||
self.commit_event(event, trans)
|
||||
@ -730,7 +730,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_tag(self, tag, trans):
|
||||
if not tag.handle:
|
||||
tag.handle = Utils.create_id()
|
||||
tag.handle = create_id()
|
||||
self.commit_event(tag, trans)
|
||||
return tag.handle
|
||||
|
||||
@ -742,7 +742,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
If not set_gid, then gramps_id is not set.
|
||||
"""
|
||||
if not obj.handle:
|
||||
obj.handle = Utils.create_id()
|
||||
obj.handle = create_id()
|
||||
if not obj.gramps_id or set_gid:
|
||||
obj.gramps_id = self.find_next_object_gramps_id()
|
||||
self.commit_media_object(obj, transaction)
|
||||
|
@ -59,7 +59,7 @@ from gen.lib import (MediaObject, Person, Family, Source, Citation, Event,
|
||||
from gen.db.dbconst import *
|
||||
from gen.utils.callback import Callback
|
||||
from gen.db import (BsddbBaseCursor, DbReadBase)
|
||||
from Utils import create_id
|
||||
from gen.utils.id import create_id
|
||||
from gen.errors import DbError
|
||||
|
||||
LOG = logging.getLogger(DBLOGNAME)
|
||||
|
@ -15,6 +15,7 @@ pkgpython_PYTHON = \
|
||||
configmanager.py \
|
||||
fallback.py \
|
||||
file.py \
|
||||
id.py \
|
||||
image.py \
|
||||
keyword.py \
|
||||
lds.py \
|
||||
|
63
src/gen/utils/id.py
Normal file
63
src/gen/utils/id.py
Normal file
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# 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$
|
||||
|
||||
"""
|
||||
Utilities to create unique identifiers
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import sys
|
||||
import random
|
||||
import time
|
||||
import uuid
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from const import GRAMPS_UUID
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# create_id
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
rand = random.Random(time.time())
|
||||
|
||||
def create_id():
|
||||
return "%08x%08x" % (int(time.time()*10000),
|
||||
rand.randint(0, sys.maxint))
|
||||
|
||||
def create_uid(self, handle=None):
|
||||
if handle:
|
||||
uid = uuid.uuid5(GRAMPS_UUID, handle)
|
||||
else:
|
||||
uid = uuid.uuid4()
|
||||
return uid.hex.upper()
|
||||
|
@ -39,7 +39,7 @@ import time
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from Utils import create_id
|
||||
from gen.utils.id import create_id
|
||||
from const import IMAGE_DIR
|
||||
from gen.ggettext import sgettext as _
|
||||
|
||||
|
@ -60,7 +60,6 @@ import gobject
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
from gen.config import config
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from gen.utils import get_marriage_or_fallback
|
||||
@ -83,6 +82,7 @@ from gui.dialog import (ErrorDialog, RunDatabaseRepair, WarningDialog,
|
||||
MessageHideDialog)
|
||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
||||
from gui.selectors import SelectorFactory
|
||||
from gen.utils.id import create_id
|
||||
from gen.utils.name import preset_name, family_name
|
||||
|
||||
SelectPerson = SelectorFactory('Person')
|
||||
@ -381,7 +381,7 @@ class EditFamily(EditPrimary):
|
||||
|
||||
self.added = self.obj.handle is None
|
||||
if self.added:
|
||||
self.obj.handle = Utils.create_id()
|
||||
self.obj.handle = create_id()
|
||||
|
||||
self.load_data()
|
||||
|
||||
|
@ -54,7 +54,7 @@ from gen.db import DbTxn
|
||||
from gen.plug.utils import OpenFileOrStdin
|
||||
from gen.datehandler import parser as _dp
|
||||
from Utils import gender as gender_map
|
||||
from Utils import create_id
|
||||
from gen.utils.id import create_id
|
||||
from gui.utils import ProgressMeter
|
||||
from gen.lib.eventroletype import EventRoleType
|
||||
|
||||
|
@ -47,7 +47,7 @@ log = logging.getLogger('.ImportProGen')
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
from gen.utils.id import create_id
|
||||
from gui.utils import ProgressMeter
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
@ -90,7 +90,7 @@ def _find_from_handle(gramps_id, table):
|
||||
"""
|
||||
intid = table.get(gramps_id)
|
||||
if not intid:
|
||||
intid = Utils.create_id()
|
||||
intid = create_id()
|
||||
table[gramps_id] = intid
|
||||
return intid
|
||||
|
||||
|
@ -48,7 +48,7 @@ import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gen.db.write import CLASS_TO_KEY_MAP
|
||||
from gen.errors import GrampsImportError
|
||||
import Utils
|
||||
from gen.utils.id import create_id
|
||||
from gen.utils.name import family_name
|
||||
from gen.utils.unknown import make_unknown, create_explanation_note
|
||||
import gen.datehandler
|
||||
@ -710,16 +710,16 @@ class GrampsParser(UpdateCallback):
|
||||
elif handle in self.import_handles:
|
||||
LOG.warn("The file you import contains duplicate handles "
|
||||
"which is illegal and being fixed now.")
|
||||
handle = Utils.create_id()
|
||||
handle = create_id()
|
||||
while handle in self.import_handles:
|
||||
handle = Utils.create_id()
|
||||
handle = create_id()
|
||||
self.import_handles[orig_handle][target] = [handle, False]
|
||||
else:
|
||||
orig_handle = handle
|
||||
if self.replace_import_handle:
|
||||
handle = Utils.create_id()
|
||||
handle = create_id()
|
||||
while handle in self.import_handles:
|
||||
handle = Utils.create_id()
|
||||
handle = create_id()
|
||||
else:
|
||||
has_handle_func = {"person": self.db.has_person_handle,
|
||||
"family": self.db.has_family_handle,
|
||||
@ -732,7 +732,7 @@ class GrampsParser(UpdateCallback):
|
||||
"note": self.db.has_note_handle,
|
||||
"tag": self.db.has_tag_handle}[target]
|
||||
while has_handle_func(handle):
|
||||
handle = Utils.create_id()
|
||||
handle = create_id()
|
||||
self.import_handles[orig_handle] = {target: [handle, False]}
|
||||
if callable(prim_obj): # method is called by a reference
|
||||
prim_obj = prim_obj()
|
||||
@ -816,9 +816,9 @@ class GrampsParser(UpdateCallback):
|
||||
raw = get_raw_obj_data(handle)
|
||||
prim_obj.unserialize(raw)
|
||||
else:
|
||||
handle = Utils.create_id()
|
||||
handle = create_id()
|
||||
while has_handle_func(handle):
|
||||
handle = Utils.create_id()
|
||||
handle = create_id()
|
||||
if callable(prim_obj):
|
||||
prim_obj = prim_obj()
|
||||
prim_obj.set_handle(handle)
|
||||
@ -1108,7 +1108,7 @@ class GrampsParser(UpdateCallback):
|
||||
self.witness_comment = ""
|
||||
if 'name' in attrs:
|
||||
note = gen.lib.Note()
|
||||
note.handle = Utils.create_id()
|
||||
note.handle = create_id()
|
||||
note.set(_("Witness name: %s") % attrs['name'])
|
||||
note.type.set(gen.lib.NoteType.EVENT)
|
||||
note.private = self.event.private
|
||||
@ -1149,7 +1149,7 @@ class GrampsParser(UpdateCallback):
|
||||
# GRAMPS LEGACY: old events that were written inside
|
||||
# person or family objects.
|
||||
self.event = gen.lib.Event()
|
||||
self.event.handle = Utils.create_id()
|
||||
self.event.handle = create_id()
|
||||
self.event.type = gen.lib.EventType()
|
||||
self.event.type.set_from_xml_str(attrs['type'])
|
||||
self.db.add_event(self.event, self.trans)
|
||||
@ -1737,7 +1737,7 @@ class GrampsParser(UpdateCallback):
|
||||
# the caller object, and inherits privacy from caller object
|
||||
# On stop_note the reference to this note will be added
|
||||
self.note = gen.lib.Note()
|
||||
self.note.handle = Utils.create_id()
|
||||
self.note.handle = create_id()
|
||||
self.note.format = int(attrs.get('format', gen.lib.Note.FLOWED))
|
||||
# The order in this long if-then statement should reflect the
|
||||
# DTD: most deeply nested elements come first.
|
||||
@ -2345,7 +2345,7 @@ class GrampsParser(UpdateCallback):
|
||||
|
||||
if text is not None:
|
||||
note = gen.lib.Note()
|
||||
note.handle = Utils.create_id()
|
||||
note.handle = create_id()
|
||||
note.set(_("Witness comment: %s") % text)
|
||||
note.type.set(gen.lib.NoteType.EVENT)
|
||||
note.private = self.event.private
|
||||
@ -2454,7 +2454,7 @@ class GrampsParser(UpdateCallback):
|
||||
if self.in_witness:
|
||||
# Parse witnesses created by older gramps
|
||||
note = gen.lib.Note()
|
||||
note.handle = Utils.create_id()
|
||||
note.handle = create_id()
|
||||
note.set(_("Witness name: %s") % tag)
|
||||
note.type.set(gen.lib.NoteType.EVENT)
|
||||
note.private = self.event.private
|
||||
@ -2684,7 +2684,7 @@ class GrampsParser(UpdateCallback):
|
||||
# This is old XML. We no longer have "text" attribute in soure_ref.
|
||||
# So we create a new note, commit, and add the handle to note list.
|
||||
note = gen.lib.Note()
|
||||
note.handle = Utils.create_id()
|
||||
note.handle = create_id()
|
||||
note.private = self.citation.private
|
||||
note.set(text)
|
||||
note.type.set(gen.lib.NoteType.SOURCE_TEXT)
|
||||
@ -2701,7 +2701,7 @@ class GrampsParser(UpdateCallback):
|
||||
else:
|
||||
text = tag
|
||||
note = gen.lib.Note()
|
||||
note.handle = Utils.create_id()
|
||||
note.handle = create_id()
|
||||
note.private = self.citation.private
|
||||
note.set(text)
|
||||
note.type.set(gen.lib.NoteType.CITATION)
|
||||
@ -2938,7 +2938,7 @@ class GrampsParser(UpdateCallback):
|
||||
self.trans,
|
||||
source_class_func=self.func_map['source'][0],
|
||||
source_commit_func=self.func_map['source'][1],
|
||||
source_class_arg={'handle':Utils.create_id(), 'id':None, 'priv':False})
|
||||
source_class_arg={'handle':create_id(), 'id':None, 'priv':False})
|
||||
elif target == 'note':
|
||||
objs = make_unknown(class_arg, expl_note.handle,
|
||||
self.func_map[target][0], self.stop_note_asothers,
|
||||
|
@ -118,9 +118,9 @@ import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gen.updatecallback import UpdateCallback
|
||||
import gen.mime
|
||||
from gen.utils.id import create_id
|
||||
from gen.utils.lds import TEMPLES
|
||||
from gen.utils.unknown import make_unknown, create_explanation_note
|
||||
import Utils
|
||||
from gen.datehandler._dateparser import DateParser
|
||||
from gen.db.dbconst import EVENT_KEY
|
||||
from gui.dialog import WarningDialog
|
||||
@ -1736,7 +1736,7 @@ class GedcomParser(UpdateCallback):
|
||||
"""
|
||||
intid = table.get(gramps_id)
|
||||
if not intid:
|
||||
intid = Utils.create_id()
|
||||
intid = create_id()
|
||||
table[gramps_id] = intid
|
||||
return intid
|
||||
|
||||
@ -2743,7 +2743,7 @@ class GedcomParser(UpdateCallback):
|
||||
if self.dbase.has_place_handle(intid):
|
||||
place.unserialize(self.dbase.get_raw_place_data(intid))
|
||||
else:
|
||||
intid = Utils.create_id()
|
||||
intid = create_id()
|
||||
place.set_handle(intid)
|
||||
place.set_title(title)
|
||||
place.set_gramps_id(new_id)
|
||||
@ -2900,7 +2900,7 @@ class GedcomParser(UpdateCallback):
|
||||
[(0, len(message))])
|
||||
text = StyledText(message, [tag])
|
||||
new_note.set_styledtext(text)
|
||||
new_note.set_handle(Utils.create_id())
|
||||
new_note.set_handle(create_id())
|
||||
note_type = gen.lib.NoteType()
|
||||
note_type.set((gen.lib.NoteType.CUSTOM, _("GEDCOM import")))
|
||||
new_note.set_type(note_type)
|
||||
@ -3082,7 +3082,7 @@ class GedcomParser(UpdateCallback):
|
||||
submitter_name = _("SUBM (Submitter): @%s@") % line.token_text
|
||||
if self.use_def_src:
|
||||
repo.set_name(submitter_name)
|
||||
repo.set_handle(Utils.create_id())
|
||||
repo.set_handle(create_id())
|
||||
repo.set_gramps_id(self.dbase.find_next_repository_gramps_id())
|
||||
|
||||
addr = gen.lib.Address()
|
||||
@ -5237,7 +5237,7 @@ class GedcomParser(UpdateCallback):
|
||||
self.__skip_subordinate_levels(state.level+2, state)
|
||||
else:
|
||||
new_note = gen.lib.Note(line.data)
|
||||
new_note.set_handle(Utils.create_id())
|
||||
new_note.set_handle(create_id())
|
||||
self.dbase.add_note(new_note, self.trans)
|
||||
self.__skip_subordinate_levels(state.level+2, state)
|
||||
state.event.add_note(new_note.get_handle())
|
||||
@ -6834,7 +6834,7 @@ class GedcomParser(UpdateCallback):
|
||||
else:
|
||||
new_note = gen.lib.Note(line.data)
|
||||
new_note.set_gramps_id(self.nid_map[""])
|
||||
new_note.set_handle(Utils.create_id())
|
||||
new_note.set_handle(create_id())
|
||||
|
||||
sub_state = CurrentState(level=state.level+1)
|
||||
sub_state.note = new_note
|
||||
@ -6957,7 +6957,7 @@ class GedcomParser(UpdateCallback):
|
||||
citation = gen.lib.Citation()
|
||||
if line.data and line.data[0] != "@":
|
||||
title = line.data
|
||||
handle = self.inline_srcs.get(title, Utils.create_id())
|
||||
handle = self.inline_srcs.get(title, create_id())
|
||||
src = gen.lib.Source()
|
||||
src.handle = handle
|
||||
src.gramps_id = self.dbase.find_next_source_gramps_id()
|
||||
|
@ -66,6 +66,7 @@ import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gen.config import config
|
||||
import Utils
|
||||
from gen.utils.id import create_id
|
||||
from gen.utils.name import family_name
|
||||
from gen.utils.unknown import make_unknown
|
||||
from gen.utils.file import (get_unicode_path_from_file_chooser,
|
||||
@ -236,7 +237,7 @@ class CheckIntegrity(object):
|
||||
'were referenced but missing so that is why they have been created '
|
||||
'when you ran Check and Repair on %s.') %
|
||||
time.strftime('%x %X', time.localtime()))
|
||||
self.explanation.set_handle(Utils.create_id())
|
||||
self.explanation.set_handle(create_id())
|
||||
|
||||
def family_errors(self):
|
||||
return (len(self.broken_parent_links) +
|
||||
@ -940,7 +941,7 @@ class CheckIntegrity(object):
|
||||
newref = birth_ref
|
||||
if birth_ref.ref is None:
|
||||
none_handle = True
|
||||
birth_ref.ref = Utils.create_id()
|
||||
birth_ref.ref = create_id()
|
||||
birth_handle = birth_ref.ref
|
||||
birth = self.db.get_event_from_handle(birth_handle)
|
||||
if not birth:
|
||||
@ -974,7 +975,7 @@ class CheckIntegrity(object):
|
||||
newref = death_ref
|
||||
if death_ref.ref is None:
|
||||
none_handle = True
|
||||
death_ref.ref = Utils.create_id()
|
||||
death_ref.ref = create_id()
|
||||
death_handle = death_ref.ref
|
||||
death = self.db.get_event_from_handle(death_handle)
|
||||
if not death:
|
||||
@ -1009,7 +1010,7 @@ class CheckIntegrity(object):
|
||||
newlist.append(event_ref)
|
||||
if event_ref.ref is None:
|
||||
none_handle = True
|
||||
event_ref.ref = Utils.create_id()
|
||||
event_ref.ref = create_id()
|
||||
event_handle = event_ref.ref
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
if not event:
|
||||
@ -1047,7 +1048,7 @@ class CheckIntegrity(object):
|
||||
newlist.append(event_ref)
|
||||
if event_ref.ref is None:
|
||||
none_handle = True
|
||||
event_ref.ref = Utils.create_id()
|
||||
event_ref.ref = create_id()
|
||||
event_handle = event_ref.ref
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
if not event:
|
||||
@ -1090,7 +1091,7 @@ class CheckIntegrity(object):
|
||||
newlist.append(pref)
|
||||
if pref.ref is None:
|
||||
none_handle = True
|
||||
pref.ref = Utils.create_id()
|
||||
pref.ref = create_id()
|
||||
p = self.db.get_person_from_handle( pref.ref)
|
||||
if not p:
|
||||
# The referenced person does not exist in the database
|
||||
@ -1144,7 +1145,7 @@ class CheckIntegrity(object):
|
||||
newlist.append(reporef)
|
||||
if reporef.ref is None:
|
||||
none_handle = True
|
||||
reporef.ref = Utils.create_id()
|
||||
reporef.ref = create_id()
|
||||
r = self.db.get_repository_from_handle(reporef.ref)
|
||||
if not r:
|
||||
# The referenced repository does not exist in the database
|
||||
@ -1249,7 +1250,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Citation':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
person.replace_citation_references(None, new_handle)
|
||||
self.db.commit_person(person, self.trans)
|
||||
self.invalid_citation_references.add(new_handle)
|
||||
@ -1265,7 +1266,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Citation':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
family.replace_citation_references(None, new_handle)
|
||||
self.db.commit_family(family, self.trans)
|
||||
self.invalid_citation_references.add(new_handle)
|
||||
@ -1281,7 +1282,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Citation':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
place.replace_citation_references(None, new_handle)
|
||||
self.db.commit_place(place, self.trans)
|
||||
self.invalid_citation_references.add(new_handle)
|
||||
@ -1297,7 +1298,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Citation':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
citation.replace_citation_references(None, new_handle)
|
||||
self.db.commit_citation(citation, self.trans)
|
||||
self.invalid_citation_references.add(new_handle)
|
||||
@ -1313,7 +1314,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Citation':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
repository.replace_citation_references(None, new_handle)
|
||||
self.db.commit_repository(repository, self.trans)
|
||||
self.invalid_citation_references.add(new_handle)
|
||||
@ -1329,7 +1330,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Citation':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
obj.replace_citation_references(None, new_handle)
|
||||
self.db.commit_media_object(obj, self.trans)
|
||||
self.invalid_citation_references.add(new_handle)
|
||||
@ -1345,7 +1346,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Citation':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
event.replace_citation_references(None, new_handle)
|
||||
self.db.commit_event(event, self.trans)
|
||||
self.invalid_citation_references.add(new_handle)
|
||||
@ -1357,7 +1358,7 @@ class CheckIntegrity(object):
|
||||
self.class_citation, self.commit_citation, self.trans,
|
||||
source_class_func=self.class_source,
|
||||
source_commit_func=self.commit_source,
|
||||
source_class_arg=Utils.create_id())
|
||||
source_class_arg=create_id())
|
||||
self.invalid_source_references.add(created[0].handle)
|
||||
|
||||
if len(self.invalid_citation_references) == 0:
|
||||
@ -1374,7 +1375,7 @@ class CheckIntegrity(object):
|
||||
citation = self.db.get_citation_from_handle(key)
|
||||
source_handle = citation.get_reference_handle()
|
||||
if source_handle is None:
|
||||
source_handle = Utils.create_id()
|
||||
source_handle = create_id()
|
||||
citation.set_reference_handle(source_handle)
|
||||
self.db.commit_citation(citation, self.trans)
|
||||
if source_handle:
|
||||
@ -1415,7 +1416,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'MediaObject':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
person.replace_media_references(None, new_handle)
|
||||
self.db.commit_person(person, self.trans)
|
||||
self.invalid_media_references.add(new_handle)
|
||||
@ -1431,7 +1432,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'MediaObject':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
family.replace_media_references(None, new_handle)
|
||||
self.db.commit_family(family, self.trans)
|
||||
self.invalid_media_references.add(new_handle)
|
||||
@ -1447,7 +1448,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'MediaObject':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
place.replace_media_references(None, new_handle)
|
||||
self.db.commit_place(place, self.trans)
|
||||
self.invalid_media_references.add(new_handle)
|
||||
@ -1463,7 +1464,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'MediaObject':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
event.replace_media_references(None, new_handle)
|
||||
self.db.commit_event(event, self.trans)
|
||||
self.invalid_media_references.add(new_handle)
|
||||
@ -1479,7 +1480,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'MediaObject':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
citation.replace_media_references(None, new_handle)
|
||||
self.db.commit_citation(citation, self.trans)
|
||||
self.invalid_media_references.add(new_handle)
|
||||
@ -1495,7 +1496,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'MediaObject':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
source.replace_media_references(None, new_handle)
|
||||
self.db.commit_source(source, self.trans)
|
||||
self.invalid_media_references.add(new_handle)
|
||||
@ -1551,7 +1552,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
person.replace_note_references(None, new_handle)
|
||||
self.db.commit_person(person, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1567,7 +1568,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
family.replace_note_references(None, new_handle)
|
||||
self.db.commit_family(family, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1583,7 +1584,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
place.replace_note_references(None, new_handle)
|
||||
self.db.commit_place(place, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1599,7 +1600,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
citation.replace_note_references(None, new_handle)
|
||||
self.db.commit_citation(citation, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1615,7 +1616,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
source.replace_note_references(None, new_handle)
|
||||
self.db.commit_source(source, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1631,7 +1632,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
obj.replace_note_references(None, new_handle)
|
||||
self.db.commit_media_object(obj, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1647,7 +1648,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
event.replace_note_references(None, new_handle)
|
||||
self.db.commit_event(event, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1663,7 +1664,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Note':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
repo.replace_note_references(None, new_handle)
|
||||
self.db.commit_repository(repo, self.trans)
|
||||
self.invalid_note_references.add(new_handle)
|
||||
@ -1703,7 +1704,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Tag':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
person.replace_tag_references(None, new_handle)
|
||||
self.db.commit_person(person, self.trans)
|
||||
self.invalid_tag_references.add(new_handle)
|
||||
@ -1719,7 +1720,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Tag':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
family.replace_tag_references(None, new_handle)
|
||||
self.db.commit_family(family, self.trans)
|
||||
self.invalid_tag_references.add(new_handle)
|
||||
@ -1735,7 +1736,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Tag':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
obj.replace_tag_references(None, new_handle)
|
||||
self.db.commit_media_object(obj, self.trans)
|
||||
self.invalid_tag_references.add(new_handle)
|
||||
@ -1751,7 +1752,7 @@ class CheckIntegrity(object):
|
||||
for item in handle_list:
|
||||
if item[0] == 'Tag':
|
||||
if item[1] is None:
|
||||
new_handle = Utils.create_id()
|
||||
new_handle = create_id()
|
||||
note.replace_tag_references(None, new_handle)
|
||||
self.db.commit_note(note, self.trans)
|
||||
self.invalid_tag_references.add(new_handle)
|
||||
|
@ -41,7 +41,7 @@ from gen.db import (PERSON_KEY,
|
||||
PLACE_KEY,
|
||||
REPOSITORY_KEY,
|
||||
NOTE_KEY)
|
||||
import Utils
|
||||
from gen.utils.id import create_id
|
||||
from webapp.libdjango import DjangoInterface
|
||||
from django.db import transaction
|
||||
|
||||
@ -941,7 +941,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_person(self, person, trans, set_gid=True):
|
||||
if not person.handle:
|
||||
person.handle = Utils.create_id()
|
||||
person.handle = create_id()
|
||||
if not person.gramps_id or set_gid:
|
||||
person.gramps_id = self.find_next_person_gramps_id()
|
||||
self.commit_person(person, trans)
|
||||
@ -949,7 +949,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_family(self, family, trans, set_gid=True):
|
||||
if not family.handle:
|
||||
family.handle = Utils.create_id()
|
||||
family.handle = create_id()
|
||||
if not family.gramps_id or set_gid:
|
||||
family.gramps_id = self.find_next_family_gramps_id()
|
||||
self.commit_family(family, trans)
|
||||
@ -957,7 +957,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_citation(self, citation, trans, set_gid=True):
|
||||
if not citation.handle:
|
||||
citation.handle = Utils.create_id()
|
||||
citation.handle = create_id()
|
||||
if not citation.gramps_id or set_gid:
|
||||
citation.gramps_id = self.find_next_citation_gramps_id()
|
||||
self.commit_citation(citation, trans)
|
||||
@ -965,7 +965,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_source(self, source, trans, set_gid=True):
|
||||
if not source.handle:
|
||||
source.handle = Utils.create_id()
|
||||
source.handle = create_id()
|
||||
if not source.gramps_id or set_gid:
|
||||
source.gramps_id = self.find_next_source_gramps_id()
|
||||
self.commit_source(source, trans)
|
||||
@ -973,7 +973,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_repository(self, repository, trans, set_gid=True):
|
||||
if not repository.handle:
|
||||
repository.handle = Utils.create_id()
|
||||
repository.handle = create_id()
|
||||
if not repository.gramps_id or set_gid:
|
||||
repository.gramps_id = self.find_next_repository_gramps_id()
|
||||
self.commit_repository(repository, trans)
|
||||
@ -981,7 +981,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_note(self, note, trans, set_gid=True):
|
||||
if not note.handle:
|
||||
note.handle = Utils.create_id()
|
||||
note.handle = create_id()
|
||||
if not note.gramps_id or set_gid:
|
||||
note.gramps_id = self.find_next_note_gramps_id()
|
||||
self.commit_note(note, trans)
|
||||
@ -989,7 +989,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_place(self, place, trans, set_gid=True):
|
||||
if not place.handle:
|
||||
place.handle = Utils.create_id()
|
||||
place.handle = create_id()
|
||||
if not place.gramps_id or set_gid:
|
||||
place.gramps_id = self.find_next_place_gramps_id()
|
||||
self.commit_place(place, trans)
|
||||
@ -997,7 +997,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_event(self, event, trans, set_gid=True):
|
||||
if not event.handle:
|
||||
event.handle = Utils.create_id()
|
||||
event.handle = create_id()
|
||||
if not event.gramps_id or set_gid:
|
||||
event.gramps_id = self.find_next_event_gramps_id()
|
||||
self.commit_event(event, trans)
|
||||
@ -1005,7 +1005,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
def add_tag(self, tag, trans):
|
||||
if not tag.handle:
|
||||
tag.handle = Utils.create_id()
|
||||
tag.handle = create_id()
|
||||
self.commit_event(tag, trans)
|
||||
return tag.handle
|
||||
|
||||
@ -1017,7 +1017,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
If not set_gid, then gramps_id is not set.
|
||||
"""
|
||||
if not obj.handle:
|
||||
obj.handle = Utils.create_id()
|
||||
obj.handle = create_id()
|
||||
if not obj.gramps_id or set_gid:
|
||||
obj.gramps_id = self.find_next_object_gramps_id()
|
||||
self.commit_media_object(obj, transaction)
|
||||
|
@ -32,7 +32,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.contenttypes import generic
|
||||
|
||||
from gen.lib.date import Date as GDate, Today
|
||||
from Utils import create_id, create_uid
|
||||
from gen.utils.id import create_id, create_uid
|
||||
|
||||
from webapp.grampsdb.profile import Profile
|
||||
|
||||
|
@ -26,7 +26,7 @@ from webapp.utils import _, boolean, update_last_changed
|
||||
from webapp.grampsdb.models import Family
|
||||
from webapp.grampsdb.forms import *
|
||||
from webapp.libdjango import DjangoInterface
|
||||
from Utils import create_id
|
||||
from gen.utils.id import create_id
|
||||
|
||||
## Django Modules
|
||||
from django.shortcuts import get_object_or_404, render_to_response, redirect
|
||||
|
Loading…
Reference in New Issue
Block a user