* 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
f7de2b1f0e
commit
feb263c48e
@ -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>
|
2005-03-31 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||||
* plugins/TestcaseGenerator.py: Added a dialog to specify what is to be generated
|
* 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.
|
and a ProgressBar. Enhanced family tree generation and randomized names a little more.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# 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
|
# 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
|
# 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
|
Provides the Berkeley DB (BSDDB) database backend for GRAMPS
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Standard python modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import locale
|
import locale
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from RelLib import *
|
|
||||||
from GrampsDbBase import *
|
|
||||||
from bsddb import dbshelve, db
|
from bsddb import dbshelve, db
|
||||||
|
|
||||||
_DBVERSION = 4
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Gramps modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from RelLib import *
|
||||||
|
from GrampsDbBase import *
|
||||||
|
|
||||||
|
_DBVERSION = 5
|
||||||
|
|
||||||
def find_surname(key,data):
|
def find_surname(key,data):
|
||||||
return str(data[3].get_surname())
|
return str(data[3].get_surname())
|
||||||
@ -89,6 +99,9 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
def get_family_cursor(self):
|
def get_family_cursor(self):
|
||||||
return GrampsBSDDBCursor(self.family_map)
|
return GrampsBSDDBCursor(self.family_map)
|
||||||
|
|
||||||
|
def get_event_cursor(self):
|
||||||
|
return GrampsBSDDBCursor(self.event_map)
|
||||||
|
|
||||||
def get_place_cursor(self):
|
def get_place_cursor(self):
|
||||||
return GrampsBSDDBCursor(self.place_map)
|
return GrampsBSDDBCursor(self.place_map)
|
||||||
|
|
||||||
@ -369,6 +382,17 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
|
|
||||||
version = self.metadata['version']
|
version = self.metadata['version']
|
||||||
if version < 2:
|
if version < 2:
|
||||||
|
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"
|
print "Upgrading to DB version 2"
|
||||||
cursor = self.get_person_cursor()
|
cursor = self.get_person_cursor()
|
||||||
data = cursor.first()
|
data = cursor.first()
|
||||||
@ -393,7 +417,8 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
self.commit_person(person,None)
|
self.commit_person(person,None)
|
||||||
data = cursor.next()
|
data = cursor.next()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
if version < 3:
|
|
||||||
|
def upgrade_3(self):
|
||||||
print "Upgrading to DB version 3"
|
print "Upgrading to DB version 3"
|
||||||
cursor = self.get_person_cursor()
|
cursor = self.get_person_cursor()
|
||||||
data = cursor.first()
|
data = cursor.first()
|
||||||
@ -408,7 +433,8 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
self.commit_person(person,None)
|
self.commit_person(person,None)
|
||||||
data = cursor.next()
|
data = cursor.next()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
if version < 4:
|
|
||||||
|
def upgrade_4(self,child_rel_notrans):
|
||||||
print "Upgrading to DB version 4"
|
print "Upgrading to DB version 4"
|
||||||
cursor = self.get_person_cursor()
|
cursor = self.get_person_cursor()
|
||||||
data = cursor.first()
|
data = cursor.first()
|
||||||
@ -433,4 +459,183 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
self.commit_person(person,None)
|
self.commit_person(person,None)
|
||||||
data = cursor.next()
|
data = cursor.next()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
self.metadata['version'] = _DBVERSION
|
|
||||||
|
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()
|
||||||
|
# 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 _
|
from gettext import gettext as _
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -322,7 +320,7 @@ class NoteBase:
|
|||||||
@param text: Text of the note
|
@param text: Text of the note
|
||||||
@type text: str
|
@type text: str
|
||||||
"""
|
"""
|
||||||
if self.note == None:
|
if not self.note:
|
||||||
self.note = Note()
|
self.note = Note()
|
||||||
self.note.set(text)
|
self.note.set(text)
|
||||||
|
|
||||||
@ -333,10 +331,9 @@ class NoteBase:
|
|||||||
@returns: the text of the current note
|
@returns: the text of the current note
|
||||||
@rtype: str
|
@rtype: str
|
||||||
"""
|
"""
|
||||||
if self.note == None:
|
if self.note:
|
||||||
return ""
|
|
||||||
else:
|
|
||||||
return self.note.get()
|
return self.note.get()
|
||||||
|
return ""
|
||||||
|
|
||||||
def set_note_format(self,val):
|
def set_note_format(self,val):
|
||||||
"""
|
"""
|
||||||
@ -710,14 +707,8 @@ class AttributeBase:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if source:
|
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 ]
|
for attribute in source.attribute_list ]
|
||||||
except:
|
|
||||||
self.attribute_list = [ Attribute(attribute) \
|
|
||||||
for attribute in source.attrlist ]
|
|
||||||
else:
|
else:
|
||||||
self.attribute_list = []
|
self.attribute_list = []
|
||||||
|
|
||||||
@ -2484,12 +2475,10 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
|||||||
self.mime = source.mime
|
self.mime = source.mime
|
||||||
self.desc = source.desc
|
self.desc = source.desc
|
||||||
self.thumb = source.thumb
|
self.thumb = source.thumb
|
||||||
self.place = source.place
|
|
||||||
else:
|
else:
|
||||||
self.path = ""
|
self.path = ""
|
||||||
self.mime = ""
|
self.mime = ""
|
||||||
self.desc = ""
|
self.desc = ""
|
||||||
self.place = ""
|
|
||||||
self.thumb = None
|
self.thumb = None
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
@ -2510,7 +2499,7 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
|||||||
"""
|
"""
|
||||||
return (self.handle, self.gramps_id, self.path, self.mime,
|
return (self.handle, self.gramps_id, self.path, self.mime,
|
||||||
self.desc, self.attribute_list, self.source_list, self.note,
|
self.desc, self.attribute_list, self.source_list, self.note,
|
||||||
self.change, self.date, self.place)
|
self.change, self.date)
|
||||||
|
|
||||||
def unserialize(self,data):
|
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.handle, self.gramps_id, self.path, self.mime, self.desc,
|
||||||
self.attribute_list, self.source_list, self.note, self.change,
|
self.attribute_list, self.source_list, self.note, self.change,
|
||||||
self.date, self.place) = data
|
self.date) = 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
|
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
@ -2568,25 +2543,6 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
|||||||
"""
|
"""
|
||||||
return self.attribute_list
|
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):
|
def set_mime_type(self,type):
|
||||||
"""
|
"""
|
||||||
Sets the MIME type associated with the MediaObject
|
Sets the MIME type associated with the MediaObject
|
||||||
|
@ -119,8 +119,9 @@ class SourceView:
|
|||||||
|
|
||||||
def button_press(self,obj,event):
|
def button_press(self,obj,event):
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||||
store,node = self.selection.get_selected()
|
mlist = []
|
||||||
handle = store.get_value(node,_HANDLE_COL)
|
self.selection.selected_foreach(self.blist,mlist)
|
||||||
|
handle = mlist[0]
|
||||||
source = self.parent.db.get_source_from_handle(handle)
|
source = self.parent.db.get_source_from_handle(handle)
|
||||||
EditSource.EditSource(source,self.parent.db,self.parent,
|
EditSource.EditSource(source,self.parent.db,self.parent,
|
||||||
self.topWindow,self.update_display)
|
self.topWindow,self.update_display)
|
||||||
|
@ -110,7 +110,7 @@ class CheckIntegrity:
|
|||||||
mother = self.db.get_person_from_handle(mother_handle)
|
mother = self.db.get_person_from_handle(mother_handle)
|
||||||
if not mother:
|
if not mother:
|
||||||
# The person referenced by the mother handle does not exist in the database
|
# 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.db.commit_family(family,self.trans)
|
||||||
self.broken_parent_links.append((mother_handle,family_handle))
|
self.broken_parent_links.append((mother_handle,family_handle))
|
||||||
mother_handle = None
|
mother_handle = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user