* src/GrampsBSDDB.py (upgrade): Delegate particular versioned
upgrades to separate methods; provide upgrade_5 method. * src/RelLib.py: Remove place from MediaObjects; minor improvements. * src/SourceView.py (button_press): Proper selection on double-click. * src/plugins/Check.py (check_for_broken_family_links): Typo. svn: r4265
This commit is contained in:
parent
4e41a60fa9
commit
6ed43eb355
@ -1,3 +1,10 @@
|
||||
2005-03-31 Alex Roitman <shura@gramps-project.org>
|
||||
* src/GrampsBSDDB.py (upgrade): Delegate particular versioned
|
||||
upgrades to separate methods; provide upgrade_5 method.
|
||||
* src/RelLib.py: Remove place from MediaObjects; minor improvements.
|
||||
* src/SourceView.py (button_press): Proper selection on double-click.
|
||||
* src/plugins/Check.py (check_for_broken_family_links): Typo.
|
||||
|
||||
2005-03-31 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* plugins/TestcaseGenerator.py: Added a dialog to specify what is to be generated
|
||||
and a ProgressBar. Enhanced family tree generation and randomized names a little more.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2004 Donald N. Allingham
|
||||
# Copyright (C) 2000-2005 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
|
||||
@ -24,16 +24,26 @@
|
||||
Provides the Berkeley DB (BSDDB) database backend for GRAMPS
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import time
|
||||
import locale
|
||||
from gettext import gettext as _
|
||||
|
||||
from RelLib import *
|
||||
from GrampsDbBase import *
|
||||
from bsddb import dbshelve, db
|
||||
|
||||
_DBVERSION = 4
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from RelLib import *
|
||||
from GrampsDbBase import *
|
||||
|
||||
_DBVERSION = 5
|
||||
|
||||
def find_surname(key,data):
|
||||
return str(data[3].get_surname())
|
||||
@ -89,6 +99,9 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
def get_family_cursor(self):
|
||||
return GrampsBSDDBCursor(self.family_map)
|
||||
|
||||
def get_event_cursor(self):
|
||||
return GrampsBSDDBCursor(self.event_map)
|
||||
|
||||
def get_place_cursor(self):
|
||||
return GrampsBSDDBCursor(self.place_map)
|
||||
|
||||
@ -369,68 +382,260 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
|
||||
version = self.metadata['version']
|
||||
if version < 2:
|
||||
print "Upgrading to DB version 2"
|
||||
cursor = self.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
person = Person()
|
||||
person.unserialize(info)
|
||||
|
||||
plist = person.get_parent_family_handle_list()
|
||||
new_list = []
|
||||
for (f,mrel,frel) in plist:
|
||||
try:
|
||||
mrel = child_rel_notrans.index(mrel)
|
||||
except:
|
||||
mrel = Person.CHILD_REL_BIRTH
|
||||
try:
|
||||
frel = child_rel_notrans.index(frel)
|
||||
except:
|
||||
frel = Person.CHILD_REL_BIRTH
|
||||
new_list.append((f,mrel,frel))
|
||||
self.upgrade_2(child_rel_notrans)
|
||||
if version < 3:
|
||||
self.upgrade_3()
|
||||
if version < 4:
|
||||
self.upgrade_4(child_rel_notrans)
|
||||
if version < 5:
|
||||
self.upgrade_5()
|
||||
self.metadata['version'] = _DBVERSION
|
||||
print 'Successfully finished all upgrades'
|
||||
|
||||
def upgrade_2(self,child_rel_notrans):
|
||||
print "Upgrading to DB version 2"
|
||||
cursor = self.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
person = Person()
|
||||
person.unserialize(info)
|
||||
|
||||
plist = person.get_parent_family_handle_list()
|
||||
new_list = []
|
||||
for (f,mrel,frel) in plist:
|
||||
try:
|
||||
mrel = child_rel_notrans.index(mrel)
|
||||
except:
|
||||
mrel = Person.CHILD_REL_BIRTH
|
||||
try:
|
||||
frel = child_rel_notrans.index(frel)
|
||||
except:
|
||||
frel = Person.CHILD_REL_BIRTH
|
||||
new_list.append((f,mrel,frel))
|
||||
person.parent_family_list = new_list
|
||||
self.commit_person(person,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
|
||||
def upgrade_3(self):
|
||||
print "Upgrading to DB version 3"
|
||||
cursor = self.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
person = Person()
|
||||
person.unserialize(info)
|
||||
|
||||
person.primary_name.date = None
|
||||
for name in person.alternate_names:
|
||||
name.date = None
|
||||
self.commit_person(person,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
|
||||
def upgrade_4(self,child_rel_notrans):
|
||||
print "Upgrading to DB version 4"
|
||||
cursor = self.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
person = Person()
|
||||
person.unserialize(info)
|
||||
|
||||
plist = person.get_parent_family_handle_list()
|
||||
new_list = []
|
||||
change = False
|
||||
for (f,mrel,frel) in plist:
|
||||
if type(mrel) == str:
|
||||
mrel = child_rel_notrans.index(mrel)
|
||||
change = True
|
||||
if type(frel) == str:
|
||||
frel = child_rel_notrans.index(frel)
|
||||
change = True
|
||||
new_list.append((f,mrel,frel))
|
||||
if change:
|
||||
person.parent_family_list = new_list
|
||||
self.commit_person(person,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
if version < 3:
|
||||
print "Upgrading to DB version 3"
|
||||
cursor = self.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
person = Person()
|
||||
person.unserialize(info)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
|
||||
person.primary_name.date = None
|
||||
for name in person.alternate_names:
|
||||
name.date = None
|
||||
def upgrade_5(self):
|
||||
print "Upgrading to DB version 5 -- this may take a while"
|
||||
# Need to rename:
|
||||
# attrlist into attribute_list in MediaRefs
|
||||
# comments into note in SourceRefs
|
||||
# in all primary and secondary objects
|
||||
# Also MediaObject gets place attribute removed
|
||||
cursor = self.get_media_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
obj = MediaObject()
|
||||
# can't use unserialize here, since the new class
|
||||
# defines tuples one element short
|
||||
(obj.handle, obj.gramps_id, obj.path, obj.mime, obj.desc,
|
||||
obj.attribute_list, obj.source_list, obj.note, obj.change,
|
||||
obj.date, junk) = info
|
||||
for src_ref in obj.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in obj.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
self.commit_media_object(obj,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
# person
|
||||
cursor = self.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
person = Person()
|
||||
person.unserialize(info)
|
||||
changed = person.media_list or person.source_list or person.attribute_list
|
||||
for media_ref in person.media_list:
|
||||
media_ref.attribute_list = media_ref.attrlist
|
||||
del media_ref.attrlist
|
||||
for src_ref in media_ref.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in media_ref.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for src_ref in person.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in person.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for o in [o for o in [person.lds_bapt,
|
||||
person.lds_endow,
|
||||
person.lds_seal] if o]:
|
||||
for src_ref in o.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
changed = True
|
||||
for name in person.alternate_names + [person.primary_name]:
|
||||
for src_ref in name.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
changed = True
|
||||
for addr in person.address_list:
|
||||
for src_ref in addr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
changed = True
|
||||
if changed:
|
||||
self.commit_person(person,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
if version < 4:
|
||||
print "Upgrading to DB version 4"
|
||||
cursor = self.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
person = Person()
|
||||
person.unserialize(info)
|
||||
|
||||
plist = person.get_parent_family_handle_list()
|
||||
new_list = []
|
||||
change = False
|
||||
for (f,mrel,frel) in plist:
|
||||
if type(mrel) == str:
|
||||
mrel = child_rel_notrans.index(mrel)
|
||||
change = True
|
||||
if type(frel) == str:
|
||||
frel = child_rel_notrans.index(frel)
|
||||
change = True
|
||||
new_list.append((f,mrel,frel))
|
||||
if change:
|
||||
person.parent_family_list = new_list
|
||||
self.commit_person(person,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
self.metadata['version'] = _DBVERSION
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
# family
|
||||
cursor = self.get_family_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
family = Family()
|
||||
family.unserialize(info)
|
||||
changed = family.media_list or family.source_list or family.attribute_list
|
||||
for media_ref in family.media_list:
|
||||
media_ref.attribute_list = media_ref.attrlist
|
||||
del media_ref.attrlist
|
||||
for src_ref in media_ref.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in media_ref.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for src_ref in family.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in family.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
if family.lds_seal:
|
||||
for src_ref in family.lds_seal.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
changed = True
|
||||
if changed:
|
||||
self.commit_family(family,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
# event
|
||||
cursor = self.get_event_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
event = Event()
|
||||
event.unserialize(info)
|
||||
changed = event.media_list or event.source_list
|
||||
for media_ref in event.media_list:
|
||||
media_ref.attribute_list = media_ref.attrlist
|
||||
del media_ref.attrlist
|
||||
for src_ref in media_ref.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in media_ref.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for src_ref in event.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
if changed:
|
||||
self.commit_event(event,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
# place
|
||||
cursor = self.get_place_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
place = Place()
|
||||
place.unserialize(info)
|
||||
changed = place.media_list or place.source_list
|
||||
for media_ref in place.media_list:
|
||||
media_ref.attribute_list = media_ref.attrlist
|
||||
del media_ref.attrlist
|
||||
for src_ref in media_ref.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in media_ref.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for src_ref in place.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
if changed:
|
||||
self.commit_place(place,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
# source
|
||||
cursor = self.get_source_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
source = Source()
|
||||
source.unserialize(info)
|
||||
changed = source.media_list
|
||||
for media_ref in source.media_list:
|
||||
media_ref.attribute_list = media_ref.attrlist
|
||||
del media_ref.attrlist
|
||||
for src_ref in media_ref.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
for attr in media_ref.attribute_list:
|
||||
for src_ref in attr.source_list:
|
||||
src_ref.note = src_ref.comments
|
||||
del src_ref.comments
|
||||
if changed:
|
||||
self.commit_source(source,None)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
|
@ -31,9 +31,7 @@ __version__ = "$Revision$"
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
import re
|
||||
|
||||
@ -322,7 +320,7 @@ class NoteBase:
|
||||
@param text: Text of the note
|
||||
@type text: str
|
||||
"""
|
||||
if self.note == None:
|
||||
if not self.note:
|
||||
self.note = Note()
|
||||
self.note.set(text)
|
||||
|
||||
@ -333,10 +331,9 @@ class NoteBase:
|
||||
@returns: the text of the current note
|
||||
@rtype: str
|
||||
"""
|
||||
if self.note == None:
|
||||
return ""
|
||||
else:
|
||||
return self.note.get()
|
||||
if self.note:
|
||||
return self.note.get()
|
||||
return ""
|
||||
|
||||
def set_note_format(self,val):
|
||||
"""
|
||||
@ -710,14 +707,8 @@ class AttributeBase:
|
||||
"""
|
||||
|
||||
if source:
|
||||
# Ugly hack: the existing objects may have their attribute lists
|
||||
# called either attr_list or attribute_list.
|
||||
try:
|
||||
self.attribute_list = [ Attribute(attribute) \
|
||||
self.attribute_list = [ Attribute(attribute) \
|
||||
for attribute in source.attribute_list ]
|
||||
except:
|
||||
self.attribute_list = [ Attribute(attribute) \
|
||||
for attribute in source.attrlist ]
|
||||
else:
|
||||
self.attribute_list = []
|
||||
|
||||
@ -2484,12 +2475,10 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
self.mime = source.mime
|
||||
self.desc = source.desc
|
||||
self.thumb = source.thumb
|
||||
self.place = source.place
|
||||
else:
|
||||
self.path = ""
|
||||
self.mime = ""
|
||||
self.desc = ""
|
||||
self.place = ""
|
||||
self.thumb = None
|
||||
|
||||
def serialize(self):
|
||||
@ -2510,7 +2499,7 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
"""
|
||||
return (self.handle, self.gramps_id, self.path, self.mime,
|
||||
self.desc, self.attribute_list, self.source_list, self.note,
|
||||
self.change, self.date, self.place)
|
||||
self.change, self.date)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
@ -2522,21 +2511,7 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.path, self.mime, self.desc,
|
||||
self.attribute_list, self.source_list, self.note, self.change,
|
||||
self.date, self.place) = data
|
||||
|
||||
|
||||
def _has_handle_reference(self,classname,handle):
|
||||
if classname == 'Place':
|
||||
return self.place == handle
|
||||
return False
|
||||
|
||||
def _remove_handle_references(self,classname,handle_list):
|
||||
if classname == 'Place' and self.place in handle_list:
|
||||
self.place = ""
|
||||
|
||||
def _replace_handle_reference(self,classname,old_handle,new_handle):
|
||||
if classname == 'Place' and self.place == old_handle:
|
||||
self.place = new_handle
|
||||
self.date) = data
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
@ -2568,25 +2543,6 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
"""
|
||||
return self.attribute_list
|
||||
|
||||
def set_place_handle(self,place_handle):
|
||||
"""
|
||||
Sets the handle of the L{Place} instance associated with the MediaRef
|
||||
|
||||
@param place_handle: L{Place} database handle
|
||||
@type place_handle: str
|
||||
"""
|
||||
self.place = place_handle
|
||||
|
||||
def get_place_handle(self):
|
||||
"""
|
||||
Returns the database handle of the L{Place} assocated with
|
||||
the object.
|
||||
|
||||
@returns: L{Place} database handle
|
||||
@rtype: str
|
||||
"""
|
||||
return self.place
|
||||
|
||||
def set_mime_type(self,type):
|
||||
"""
|
||||
Sets the MIME type associated with the MediaObject
|
||||
|
@ -119,8 +119,9 @@ class SourceView:
|
||||
|
||||
def button_press(self,obj,event):
|
||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||
store,node = self.selection.get_selected()
|
||||
handle = store.get_value(node,_HANDLE_COL)
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
handle = mlist[0]
|
||||
source = self.parent.db.get_source_from_handle(handle)
|
||||
EditSource.EditSource(source,self.parent.db,self.parent,
|
||||
self.topWindow,self.update_display)
|
||||
|
@ -110,7 +110,7 @@ class CheckIntegrity:
|
||||
mother = self.db.get_person_from_handle(mother_handle)
|
||||
if not mother:
|
||||
# The person referenced by the mother handle does not exist in the database
|
||||
family.set_father_handle(None)
|
||||
family.set_mother_handle(None)
|
||||
self.db.commit_family(family,self.trans)
|
||||
self.broken_parent_links.append((mother_handle,family_handle))
|
||||
mother_handle = None
|
||||
|
Loading…
Reference in New Issue
Block a user