First pass at ZODB support

svn: r994
This commit is contained in:
Don Allingham 2002-05-18 16:29:04 +00:00
parent fe470d9e3a
commit 3538e1ee56
17 changed files with 655 additions and 519 deletions

View File

@ -39,6 +39,12 @@ import VersionControl
from intl import gettext
_ = gettext
try:
import ZODB
_zodb = 1
except:
_zodb = 0
#-------------------------------------------------------------------------
#
# DbPrompter
@ -60,11 +66,18 @@ class DbPrompter:
"on_opendb_delete_event": self.open_delete_event,
})
self.new = opendb.get_widget("new")
self.zodb = opendb.get_widget("zodb")
if self.want_new:
self.new.set_active(1)
if _zodb:
self.zodb.show()
def open_ok_clicked(self,obj):
if self.new.get_active():
self.db.clear_database(0)
self.save_as_activate()
elif self.zodb.get_active():
self.db.clear_database(1)
self.save_as_activate()
else:
self.open_activate()
@ -110,7 +123,6 @@ class DbPrompter:
return
Utils.destroy_passed_object(obj)
self.db.clear_database()
if self.getoldrev.get_active():
vc = VersionControl.RcsVersionControl(filename)

View File

@ -249,7 +249,7 @@ class EditPerson:
self.autoplace = AutoComp.AutoCombo(self.bpcombo,self.pmap.keys())
self.autodeath = AutoComp.AutoCombo(self.dpcombo,self.pmap.keys(),
self.autoplace)
self.comp = AutoComp.AutoCombo(self.sncombo,const.surnames)
self.comp = AutoComp.AutoCombo(self.sncombo,self.db.getSurnames())
self.gid.set_text(person.getId())
self.gid.set_editable(GrampsCfg.id_edit)
@ -1140,9 +1140,7 @@ class EditPerson:
if surname != name.getSurname():
name.setSurname(surname)
if surname not in const.surnames:
const.surnames.append(surname)
const.surnames.sort()
self.db.addSurname(name)
if given != name.getFirstName():
name.setFirstName(given)

View File

@ -84,6 +84,9 @@ class MediaView:
self.media_list.set_sort_column(self.sort_map[self.sort_col])
self.set_arrow(self.sort_col)
def change_db(self,db):
self.db = db
def moveto(self,row):
self.media_list.unselect_all()
self.media_list.select_row(row,0)
@ -260,7 +263,7 @@ class MediaView:
object = self.media_list.get_row_data(self.media_list.selection[0])
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
def on_delete_media_clicked(self,obj):
def on_delete_clicked(self,obj):
if len(self.media_list.selection) <= 0:
return
else:

View File

@ -57,7 +57,7 @@ class NameEditor:
self.type_field = self.top.get_widget("name_type")
self.note_field = self.top.get_widget("alt_note")
slist = self.top.get_widget("alt_surname_list")
self.combo = AutoComp.AutoCombo(slist,const.surnames)
self.combo = AutoComp.AutoCombo(slist,self.parent.db.getSurnames())
self.priv = self.top.get_widget("priv")
types = const.NameTypesMap.keys()
@ -138,9 +138,7 @@ class NameEditor:
if self.name.getSurname() != last:
self.name.setSurname(last)
if last not in const.surnames:
const.surnames.append(last)
const.surnames.sort()
self.parent.db.addSurname(last)
self.parent.lists_changed = 1
if self.name.getSuffix() != suffix:

View File

@ -93,6 +93,9 @@ class PlaceView:
self.place_list.set_sort_column(self.sort_map[self.sort_col])
self.place_list.set_sort_type(self.sort_dir)
def change_db(self,db):
self.db = db
def load_places(self):
"""Rebuilds the entire place view. This can be very time consuming
on large databases, and should only be called when absolutely
@ -105,23 +108,12 @@ class PlaceView:
self.place_list.freeze()
self.place_list.clear()
self.place_list.set_column_visibility(1,GrampsCfg.id_visible)
index = 0
u = string.upper
for src in self.db.getPlaceMap().values():
title = src.get_title()
id = src.getId()
mloc = src.get_main_location()
city = mloc.get_city()
county = mloc.get_county()
state = mloc.get_state()
parish = mloc.get_parish()
country = mloc.get_country()
self.place_list.append([title,id,parish,city,county,state,country,
u(title), u(parish), u(city),
u(county),u(state), u(country)])
for key in self.db.getPlaceKeys():
src = self.db.getPlaceMap()[key]
self.place_list.append(src.getDisplayInfo())
self.place_list.set_row_data(index,src)
index = index + 1
@ -194,18 +186,7 @@ class PlaceView:
obj.thaw()
def insert_place(self,place):
title = place.get_title()
id = place.getId()
mloc = place.get_main_location()
city = mloc.get_city()
county = mloc.get_county()
state = mloc.get_state()
parish = mloc.get_parish()
country = mloc.get_country()
u = string.upper
self.place_list.append([title,id,parish,city,county,state,country,
u(title), u(parish), u(city),
u(county),u(state), u(country)])
self.place_list.append(place.getDisplayInfo())
self.place_list.set_row_data(self.place_list.rows-1,place)
def new_place_after_edit(self,place):
@ -231,7 +212,7 @@ class PlaceView:
self.place_list.select_row(row,0)
self.place_list.moveto(row)
def on_delete_place_clicked(self,obj):
def on_delete_clicked(self,obj):
if len(obj.selection) == 0:
return
elif len(obj.selection) > 1:

View File

@ -41,7 +41,7 @@ class QuickAdd:
self.window.editable_enters(self.xml.get_widget("given"))
self.window.editable_enters(self.xml.get_widget("surname"))
self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"),
const.surnames)
self.db.getSurnames())
def close(self,obj):
surname = self.xml.get_widget("surname").get_text()

View File

@ -23,26 +23,75 @@
__author__ = "Don Allingham"
#-------------------------------------------------------------------------
#
# standard python modules
#
#-------------------------------------------------------------------------
from re import compile
from Date import Date, compare_dates, not_too_old
from string import strip
from string import strip, upper
import os
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Date import Date, compare_dates, not_too_old
import sort
import const
#-------------------------------------------------------------------------
#
# Attempt to load the ZODB libraries, otherwise provide alternates
#
#-------------------------------------------------------------------------
try:
from ZODB import Persistent
from ZODB.PersistentList import PersistentList
except ImportError:
class Persistent:
pass
from UserList import UserList
class PersistentList(UserList):
pass
#-------------------------------------------------------------------------
#
# Confidence levels
#
#-------------------------------------------------------------------------
CONF_VERY_HIGH = 4
CONF_HIGH = 3
CONF_NORMAL = 2
CONF_LOW = 1
CONF_VERY_LOW = 0
#-------------------------------------------------------------------------
#
# ID regular expression
#
#-------------------------------------------------------------------------
_id_reg = compile("%\d+d")
class SourceNote:
def extlist(lst):
return lst[:] # Make a copy.
def extmap(map):
return map
class SourceNote(Persistent):
"""Base class for storing source references and notes"""
def __init__(self,source=None):
"""Create a new SourceNote, copying from source if not None"""
self.source_list = []
self.source_list = PersistentList()
if source:
if len(source.source_list) > 0:
@ -58,10 +107,11 @@ class SourceNote:
def addSourceRef(self,id) :
"""Set the source reference"""
self.source_list.append(id)
self._p_changed = 1
def getSourceRefList(self) :
"""Return the source reference"""
return self.source_list
return extlist(self.source_list)
def setSourceRefList(self,list) :
"""Replaces the source reference"""
@ -219,14 +269,14 @@ class Place(SourceNote):
self.lat = source.lat
self.title = source.title
self.main_loc = Location(source.main_loc)
self.alt_loc = []
self.alt_loc = PersistentList()
for loc in source.alt_loc:
self.alt_loc = Location(loc)
self.id = source.id
self.urls = []
self.urls = PersistentList()
for u in source.urls:
self.urls.append(Url(u))
self.photoList = []
self.photoList = PersistentList()
for photo in source.photoList:
self.photoList.append(ObjectRef(photo))
else:
@ -234,14 +284,14 @@ class Place(SourceNote):
self.lat = ""
self.title = ""
self.main_loc = None
self.alt_loc = []
self.alt_loc = PersistentList()
self.id = ""
self.urls = []
self.photoList = []
self.urls = PersistentList()
self.photoList = PersistentList()
def getUrlList(self):
"""Return the list of URLs"""
return self.urls
return extlist(self.urls)
def setUrlList(self,list):
"""Replace the current URL list with the new one"""
@ -250,6 +300,7 @@ class Place(SourceNote):
def addUrl(self,url):
"""Add a URL to the URL list"""
self.urls.append(url)
self._p_changed = 1
def setId(self,id):
"""Sets the gramps ID for the place object"""
@ -295,7 +346,7 @@ class Place(SourceNote):
def get_alternate_locations(self):
"""Returns a list of alternate location information objects"""
return self.alt_loc
return extlist(self.alt_loc)
def set_alternate_locations(self,list):
"""Replaces the current alternate location list with the new one"""
@ -305,20 +356,33 @@ class Place(SourceNote):
"""Adds a Location to the alternate location list"""
if loc not in self.alt_loc:
self.alt_loc.append(loc)
self._p_changed = 1
def addPhoto(self,photo):
"""Adds a Photo object to the place object's image list"""
self.photoList.append(photo)
self._p_changed = 1
def getPhotoList(self):
"""Returns the list of Photo objects"""
return self.photoList
return extlist(self.photoList)
def setPhotoList(self,list):
"""Sets the list of Photo objects"""
self.photoList = list
class Researcher:
def getDisplayInfo(self):
if self.main_loc:
return [self.title,self.id,self.main_loc.parish,self.main_loc.city,
self.main_loc.county,self.main_loc.state,self.main_loc.country,
upper(self.title), upper(self.main_loc.parish),
upper(self.main_loc.city), upper(self.main_loc.county),
upper(self.main_loc.state), upper(self.main_loc.country)]
else:
return [self.title,self.id,'','','','','',
upper(self.title), '','','','','']
class Researcher(Persistent):
"""Contains the information about the owner of the database"""
def __init__(self):
@ -383,7 +447,7 @@ class Researcher:
if email:
self.email = strip(email)
class Location:
class Location(Persistent):
"""Provides information about a place, including city, county, state,
and country. Multiple Location objects can represent the same place,
since names of citys, countys, states, and even countries can change
@ -447,7 +511,7 @@ class Location:
"""returns the country name of the Location object"""
return self.country
class Note:
class Note(Persistent):
"""Provides general text information"""
def __init__(self,text = ""):
@ -475,7 +539,7 @@ class Photo(SourceNote):
SourceNote.__init__(self,source)
self.attrlist = []
self.attrlist = PersistentList()
if source:
self.path = source.path
self.mime = source.mime
@ -534,18 +598,20 @@ class Photo(SourceNote):
but provides a means for XML users to attach other properties to
the image"""
self.attrlist.append(attr)
self._p_changed = 1
def getAttributeList(self):
"""returns the property list associated with the image"""
return self.attrlist
return extlist(self.attrlist)
def setAttributeList(self,list):
self.attrlist = list
class ObjectRef:
class ObjectRef(Persistent):
"""Object reference class"""
def __init__(self,source=None):
self.attrlist = []
self.attrlist = PersistentList()
if source:
self.private = source.private
self.ref = source.ref
@ -600,15 +666,17 @@ class ObjectRef:
but provides a means for XML users to attach other properties to
the image"""
self.attrlist.append(attr)
self._p_changed = 1
def getAttributeList(self):
"""returns the property list associated with the image"""
return self.attrlist
return extlist(self.attrlist)
def setAttributeList(self,list):
"""sets the property list associated with the image"""
self.attrlist = list
class Attribute(DataObj):
"""Provides a simple key/value pair for describing properties. Used
by the Person and Family objects to store descriptive information."""
@ -645,7 +713,8 @@ class Address(DataObj):
"""Provides address information for a person"""
def __init__(self,source=None):
"""Creates a new Address instance, copying from the source if provided"""
"""Creates a new Address instance, copying from the source
if provided"""
DataObj.__init__(self,source)
if source:
@ -726,6 +795,7 @@ class Address(DataObj):
"""returns the postal code of the Address"""
return self.postal
class Name(DataObj):
"""Provides name information about a person. A person may have more
that one name throughout his or her life."""
@ -788,8 +858,8 @@ class Name(DataObj):
return self.Title
def getName(self):
"""returns a name string built from the components of the Name instance,
in the form of Surname, Firstname"""
"""returns a name string built from the components of the Name
instance, in the form of Surname, Firstname"""
if (self.Suffix == ""):
return "%s, %s" % (self.Surname, self.FirstName)
@ -797,15 +867,16 @@ class Name(DataObj):
return "%s, %s %s" % (self.Surname, self.FirstName, self.Suffix)
def getRegularName(self):
"""returns a name string built from the components of the Name instance,
in the form of Firstname Surname"""
"""returns a name string built from the components of the Name
instance, in the form of Firstname Surname"""
if (self.Suffix == ""):
return "%s %s" % (self.FirstName, self.Surname)
else:
return "%s %s, %s" % (self.FirstName, self.Surname, self.Suffix)
def are_equal(self,other):
"""compares to names to see if they are equal, return 0 if they are not"""
"""compares to names to see if they are equal, return 0 if they
are not"""
if self.FirstName != other.FirstName:
return 0
if self.Surname != other.Surname:
@ -828,10 +899,9 @@ class Name(DataObj):
if not a.are_equal(olist[index]):
return 0
index = index + 1
return 1
class Url:
class Url(Persistent):
"""Contains information related to internet Uniform Resource Locators,
allowing gramps to store information about internet resources"""
@ -880,7 +950,8 @@ class Url:
return 0
return 1
class Person:
class Person(Persistent):
"""Represents an individual person in the gramps database"""
unknown = 2
@ -892,18 +963,18 @@ class Person:
self.id = ""
self.PrimaryName = None
self.EventList = []
self.FamilyList = []
self.AltFamilyList = []
self.photoList = []
self.EventList = PersistentList()
self.FamilyList = PersistentList()
self.AltFamilyList = PersistentList()
self.photoList = PersistentList()
self.nickname = ""
self.alternateNames = []
self.alternateNames = PersistentList()
self.gender = 2
self.death = None
self.birth = None
self.addressList = []
self.attributeList = []
self.urls = []
self.addressList = PersistentList()
self.attributeList = PersistentList()
self.urls = PersistentList()
self.note = None
self.paf_uid = ""
self.position = None
@ -912,8 +983,23 @@ class Person:
self.lds_endow = None
self.lds_seal = None
def getDisplayInfo(self):
if self.gender == Person.male:
gender = const.male
elif self.gender == Person.female:
gender = const.female
else:
gender = const.unknown
bday = self.getBirth().getDateObj()
dday = self.getDeath().getDateObj()
return [self.PrimaryName.getName(),self.id,gender,bday.getQuoteDate(),
dday.getQuoteDate(),sort.build_sort_name(self.PrimaryName),
sort.build_sort_date(bday),sort.build_sort_date(dday)]
def setPrimaryName(self,name):
"""sets the primary name of the Person to the specified Name instance"""
"""sets the primary name of the Person to the specified
Name instance"""
self.PrimaryName = name
def getPrimaryName(self):
@ -932,7 +1018,7 @@ class Person:
def getAlternateNames(self):
"""returns the list of alternate Names"""
return self.alternateNames
return extlist(self.alternateNames)
def setAlternateNames(self,list):
"""changes the list of alternate names to the passed list"""
@ -941,10 +1027,11 @@ class Person:
def addAlternateName(self,name):
"""adds an alternate Name instance to the list"""
self.alternateNames.append(name)
self._p_changed = 1
def getUrlList(self):
"""returns the list of URL instances"""
return self.urls
return extlist(self.urls)
def setUrlList(self,list):
"""sets the list of URL instances to list"""
@ -953,6 +1040,7 @@ class Person:
def addUrl(self,url):
"""adds a URL instance to the list"""
self.urls.append(url)
self._p_changed = 1
def setId(self,id):
"""sets the gramps ID for the Person"""
@ -1003,10 +1091,11 @@ class Person:
def addPhoto(self,photo):
"""adds a Photo instance to the image list"""
self.photoList.append(photo)
self._p_changed = 1
def getPhotoList(self):
"""returns the list of Photos"""
return self.photoList
return extlist(self.photoList)
def setPhotoList(self,list):
"""Sets the list of Photo objects"""
@ -1015,10 +1104,11 @@ class Person:
def addEvent(self,event):
"""adds an Event to the event list"""
self.EventList.append(event)
self._p_changed = 1
def getEventList(self):
"""returns the list of Event instances"""
return self.EventList
return extlist(self.EventList)
def setEventList(self,list):
"""sets the event list to the passed list"""
@ -1029,6 +1119,7 @@ class Person:
families/marriages/partnerships in which the person is a
parent or spouse"""
self.FamilyList.append(family)
self._p_changed = 1
def setPreferred(self,family):
if family in self.FamilyList:
@ -1038,26 +1129,32 @@ class Person:
def getFamilyList(self) :
"""returns the list of Family instances in which the
person is a parent or spouse"""
return self.FamilyList
return extlist(self.FamilyList)
def clearFamilyList(self) :
self.FamilyList = PersistentList()
def removeFamily(self,family):
"""removes the specified Family instance from the list
of marriages/partnerships"""
if family in self.FamilyList:
self.FamilyList.remove(family)
self._p_changed = 1
def addAddress(self,address):
"""adds the Address instance to the list of addresses"""
self.addressList.append(address)
self._p_changed = 1
def removeAddress(self,address):
"""removes the Address instance from the list of addresses"""
for address in self.addressList:
if address in self.addressList:
self.addressList.remove(address)
self._p_changed = 1
def getAddressList(self):
"""returns the list of addresses"""
return self.addressList
return extlist(self.addressList)
def setAddressList(self,list):
"""sets the address list to the specified list"""
@ -1066,15 +1163,17 @@ class Person:
def addAttribute(self,attribute):
"""adds an Attribute instance to the attribute list"""
self.attributeList.append(attribute)
self._p_changed = 1
def removeAttribute(self,attribute):
"""removes the specified Attribute instance from the attribute list"""
for attribute in self.attributeList:
if attribute in self.attributeList:
self.attributeList.remove(attribute)
self._p_changed = 1
def getAttributeList(self):
"""returns the attribute list"""
return self.attributeList
return extlist(self.attributeList)
def setAttributeList(self,list):
"""sets the attribute list to the specified list"""
@ -1083,18 +1182,22 @@ class Person:
def getParentList(self):
"""returns the list of alternate Family instances, in which the Person
is a child of the family, but not a natural child of both parents"""
return self.AltFamilyList
return extlist(self.AltFamilyList)
def addAltFamily(self,family,mrel,frel):
"""adds a Family to the alternate family list, indicating the
relationship to the mother (mrel) and the father (frel)"""
self.AltFamilyList.append((family,mrel,frel))
def clearAltFamilyList(self):
self.AltFamilyList = PersistentList()
def removeAltFamily(self,family):
"""removes a Family instance from the alternate family list"""
for f in self.AltFamilyList[:]:
if f[0] == family:
self.AltFamilyList.remove(f)
self._p_changed = 1
return f
else:
return None
@ -1170,10 +1273,10 @@ class Person:
if family.Father:
# Don't waste time if the ancestor is already flagged.
# This will happen when cousins marry.
if not family.Father.ancestor:
if not family.Father.getAncestor():
family.Father.setAncestor(value)
if family.Mother:
if not family.Mother.ancestor:
if family.getMother():
if not family.Mother.getAncestor():
family.Mother.setAncestor(value)
def getAncestor(self):
@ -1330,22 +1433,23 @@ class Event(DataObj):
"""sets the Date object associated with the Event"""
self.date = date
class Family:
class Family(Persistent):
"""Represents a family unit in the gramps database"""
def __init__(self):
"""creates a new Family instance"""
self.Father = None
self.Mother = None
self.Children = []
self.Children = PersistentList()
self.Marriage = None
self.Divorce = None
self.type = "Married"
self.EventList = []
self.EventList = PersistentList()
self.id = ""
self.photoList = []
self.photoList = PersistentList()
self.note = Note()
self.attributeList = []
self.attributeList = PersistentList()
self.position = None
self.lds_seal = None
@ -1366,15 +1470,17 @@ class Family:
def addAttribute(self,attribute) :
"""adds an Attribute instance to the attribute list"""
self.attributeList.append(attribute)
self._p_changed = 1
def removeAttribute(self,attribute):
"""removes the specified Attribute instance from the attribute list"""
for attribute in self.attributeList:
if attribute in self.attributeList:
self.attributeList.remove(attribute)
self._p_changed = 1
def getAttributeList(self) :
"""returns the attribute list"""
return self.attributeList
return extlist(self.attributeList)
def setAttributeList(self,list) :
"""sets the attribute list to the specified list"""
@ -1448,7 +1554,8 @@ class Family:
to the child list"""
if person not in self.Children:
self.Children.append(person)
if person.ancestor:
self._p_changed = 1
if person.getAncestor():
if self.Father:
self.Father.setAncestor(1)
if self.Mother:
@ -1458,7 +1565,8 @@ class Family:
"""removes the specified Person from the child list"""
if person in self.Children:
self.Children.remove(person)
if person.ancestor:
self._p_changed = 1
if person.getAncestor():
if self.Father:
self.Father.setAncestor(0)
if self.Mother:
@ -1466,7 +1574,7 @@ class Family:
def getChildList(self):
"""returns the list of children"""
return self.Children
return extlist(self.Children)
def setChildList(self, list):
"""sets the list of children"""
@ -1489,10 +1597,11 @@ class Family:
def addEvent(self,event):
"""adds an Event to the event list"""
self.EventList.append(event)
self._p_changed = 1
def getEventList(self) :
"""returns the list of Event instances"""
return self.EventList
return extlist(self.EventList)
def setEventList(self,list) :
"""sets the event list to the passed list"""
@ -1501,22 +1610,26 @@ class Family:
def addPhoto(self,photo):
"""Adds a Photo object to the Family instance's image list"""
self.photoList.append(photo)
self._p_changed = 1
def getPhotoList(self):
"""Returns the list of Photo objects"""
return self.photoList
return extlist(self.photoList)
def setPhotoList(self,list):
"""Sets the list of Photo objects"""
self.photoList = list
def unique_note(self):
self.note = Note(self.note.get())
def someChildIsAncestor(self):
for child in self.Children:
if (child.ancestor):
if (child.getAncestor()):
return 1
return None
class Source:
class Source(Persistent):
"""A record of a source of information"""
def __init__(self):
@ -1526,9 +1639,13 @@ class Source:
self.pubinfo = ""
self.callno = ""
self.note = Note()
self.photoList = []
self.photoList = PersistentList()
self.id = ""
def getDisplayInfo(self):
return [self.title,self.id,self.author,upper(self.title),
upper(self.author)]
def setId(self,newId):
"""sets the gramps' ID for the Source instance"""
self.id = str(newId)
@ -1540,10 +1657,11 @@ class Source:
def addPhoto(self,photo):
"""Adds a Photo object to the Source instance's image list"""
self.photoList.append(photo)
self._p_changed = 1
def getPhotoList(self):
"""Returns the list of Photo objects"""
return self.photoList
return extlist(self.photoList)
def setPhotoList(self,list):
"""Sets the list of Photo objects"""
@ -1602,7 +1720,7 @@ class Source:
of the Source"""
return self.callno
class SourceRef:
class SourceRef(Persistent):
"""Source reference, containing detailed information about how a
referenced source relates to it"""
@ -1699,11 +1817,15 @@ class SourceRef:
#
#
#-------------------------------------------------------------------------
class GrampsDB:
class GrampsDB(Persistent):
"""Gramps database object"""
def __init__(self):
"""creates a new GrampsDB"""
self.surnames = PersistentList()
self.personTable = {}
self.placeTable = {}
self.sourceTable = {}
self.iprefix = "I%d"
self.sprefix = "S%d"
self.oprefix = "O%d"
@ -1715,6 +1837,18 @@ class GrampsDB:
self.placeMap = {}
self.new()
def get_base(self):
return ""
def need_autosave(self):
return 1
def getPersonKeys(self):
return self.personTable.keys()
def getPersonDisplay(self,key):
return self.personTable[key]
def set_iprefix(self,val):
if _id_reg.search(val):
self.iprefix = val
@ -1756,10 +1890,11 @@ class GrampsDB:
self.familyMap = {}
for p in self.personMap.values():
p.AltFamilyList = []
p.FamilyList = []
self.personMap = {}
p.clearAltFamilyList()
p.clearFamilyList()
self.surnames = PersistentList()
self.personMap = {}
self.sourceMap = {}
self.placeMap = {}
self.objectMap = {}
@ -1770,13 +1905,21 @@ class GrampsDB:
self.omapIndex = 0
self.default = None
self.owner = Researcher()
self.bookmarks = []
self.bookmarks = PersistentList()
self.path = ""
self.place2title = {}
def getSurnames(self):
return self.surnames
def addSurname(self,name):
if name and name not in self.surnames:
self.surnames.append(name)
self.surnames.sort()
def getBookmarks(self):
"""returns the list of Person instances in the bookmarks"""
return self.bookmarks
return extlist(self.bookmarks)
def clean_bookmarks(self):
"""cleans up the bookmark list, removing empty slots"""
@ -1809,7 +1952,7 @@ class GrampsDB:
def getPersonMap(self):
"""returns a map of gramps's IDs to Person instances"""
return self.personMap
return extmap(self.personMap)
def setPersonMap(self,map):
"""sets the map of gramps's IDs to Person instances"""
@ -1817,7 +1960,7 @@ class GrampsDB:
def getPlaceMap(self):
"""returns a map of gramps's IDs to Place instances"""
return self.placeMap
return extmap(self.placeMap)
def setPlaceMap(self,map):
"""sets the map of gramps's IDs to Place instances"""
@ -1825,7 +1968,7 @@ class GrampsDB:
def getFamilyMap(self):
"""returns a map of gramps's IDs to Family instances"""
return self.familyMap
return extmap(self.familyMap)
def setFamilyMap(self,map):
"""sets the map of gramps's IDs to Family instances"""
@ -1833,7 +1976,8 @@ class GrampsDB:
def getSourceMap(self):
"""returns a map of gramps's IDs to Source instances"""
return self.sourceMap
return extmap(self.sourceMap)
def getObjectMap(self):
"""returns a map of gramps's IDs to Object instances"""
@ -1895,6 +2039,12 @@ class GrampsDB:
map[family.getRelationship()] = 1
return map.keys()
def removePerson(self,id):
del self.personMap[id]
def addPersonAs(self,person):
self.personMap[person.getId()] = person
def addPerson(self,person):
"""adds a Person to the database, assigning a gramps' ID"""
index = self.iprefix % self.pmapIndex
@ -2054,6 +2204,12 @@ class GrampsDB:
self.lmapIndex = self.lmapIndex + 1
return index
def removePlace(self,id):
del self.placeMap[id]
def addPlaceAs(self,place):
self.placeMap[place.getId()] = place
def findPlace(self,idVal,map):
"""finds a Place in the database using the idVal and map
variables to translate between the external ID and gramps'
@ -2092,6 +2248,18 @@ class GrampsDB:
self.lmapIndex = self.lmapIndex + 1
return place
def getPlaceKeys(self):
return self.placeTable.keys()
def getPlaceDisplay(self,key):
return self.placeTable[key]
def getSourceKeys(self):
return self.sourceTable.keys()
def getSourceDisplay(self,key):
return self.sourceTable[key]
def newFamily(self):
"""adds a Family to the database, assigning a gramps' ID"""
index = self.fprefix % self.fmapIndex

View File

@ -244,7 +244,7 @@ class NewChild:
self.surname = self.xml.get_widget("surname")
self.given = self.xml.get_widget("childGiven")
if GrampsCfg.autocomp:
self.comp = AutoComp.AutoEntry(self.surname,const.surnames)
self.comp = AutoComp.AutoEntry(self.surname,self.db.getSurnames())
self.surname.set_text(self.update_surname(2))

View File

@ -71,13 +71,16 @@ class SourceView:
self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow]
self.source_list.connect('click-column',self.click_column)
self.sort_col,self.sort_dir = GrampsCfg.get_sort_cols("source",3,GTK.SORT_ASCENDING)
if self.sort_col >= len(self.sort_arrow):
self.sort_col = 0
self.scol,self.sdir = GrampsCfg.get_sort_cols("source",3,GTK.SORT_ASCENDING)
if self.scol >= len(self.sort_arrow):
self.scol = 0
self.source_list.set_sort_type(self.sort_dir)
self.source_list.set_sort_column(self.sort_map[self.sort_col])
self.set_arrow(self.sort_col)
self.source_list.set_sort_type(self.sdir)
self.source_list.set_sort_column(self.sort_map[self.scol])
self.set_arrow(self.scol)
def change_db(self,db):
self.db = db
def moveto(self,row):
self.source_list.unselect_all()
@ -91,7 +94,7 @@ class SourceView:
a = self.sort_arrow[column]
a.show()
if self.sort_dir == GTK.SORT_ASCENDING:
if self.sdir == GTK.SORT_ASCENDING:
a.set(GTK.ARROW_DOWN,2)
else:
a.set(GTK.ARROW_UP,2)
@ -107,20 +110,20 @@ class SourceView:
data = obj.get_row_data(obj.selection[0])
obj.freeze()
if new_col == self.sort_col:
if self.sort_dir == GTK.SORT_ASCENDING:
self.sort_dir = GTK.SORT_DESCENDING
if new_col == self.scol:
if self.sdir == GTK.SORT_ASCENDING:
self.sdir = GTK.SORT_DESCENDING
else:
self.sort_dir = GTK.SORT_ASCENDING
self.sdir = GTK.SORT_ASCENDING
else:
self.sort_dir = GTK.SORT_ASCENDING
self.sdir = GTK.SORT_ASCENDING
self.set_arrow(column)
obj.set_sort_type(self.sort_dir)
obj.set_sort_type(self.sdir)
obj.set_sort_column(new_col)
self.sort_col = new_col
GrampsCfg.save_sort_cols("source",self.sort_col,self.sort_dir)
self.scol = new_col
GrampsCfg.save_sort_cols("source",self.scol,self.sdir)
obj.sort()
if data:
row = obj.find_row_from_data(data)
@ -139,13 +142,9 @@ class SourceView:
self.source_list.set_column_visibility(1,GrampsCfg.id_visible)
index = 0
for src in self.db.getSourceMap().values():
id = src.getId()
title = src.getTitle()
author = src.getAuthor()
stitle = string.upper(title)
sauthor = string.upper(author)
self.source_list.append([title,id,author,stitle,sauthor])
for key in self.db.getSourceKeys():
src = self.db.getSourceMap()[key]
self.source_list.append(src.getDisplayInfo())
self.source_list.set_row_data(index,src)
index = index + 1
@ -156,17 +155,18 @@ class SourceView:
self.source_list.sort()
self.source_list.thaw()
def on_button_press_event(self,obj,event):
def button_press(self,obj,event):
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
if len(obj.selection) > 0:
index = obj.selection[0]
source = obj.get_row_data(index)
EditSource.EditSource(source,self.db,self.update_display_after_edit)
EditSource.EditSource(source,self.db,
self.update_display_after_edit)
def on_add_source_clicked(self,obj):
EditSource.EditSource(Source(),self.db,self.new_source_after_edit)
def on_delete_source_clicked(self,obj):
def on_delete_clicked(self,obj):
if len(obj.selection) == 0:
return
else:
@ -228,7 +228,8 @@ class SourceView:
if len(obj.selection) > 0:
index = obj.selection[0]
source = obj.get_row_data(index)
EditSource.EditSource(source,self.db,self.update_display_after_edit)
EditSource.EditSource(source,self.db,
self.update_display_after_edit)
def new_source_after_edit(self,source):
self.db.addSource(source)

View File

@ -429,20 +429,6 @@ def thumb_path(dir,mobj):
else:
return find_icon(type)
#-------------------------------------------------------------------------
#
#
# Common setup code for a combo box for inputting a surname.
#
#-------------------------------------------------------------------------
def attach_surnames(combo):
if len(const.surnames) > 0:
# Surnames are always sorted
combo.set_popdown_strings(const.surnames)
combo.disable_activate()
combo.entry.set_text("")
#-------------------------------------------------------------------------
#
# Sets up a delayed (0.005 sec) handler for text completion. Text

View File

@ -157,14 +157,14 @@ class XmlWriter:
date = string.split(time.ctime(time.time()))
owner = self.db.getResearcher()
personList = self.db.getPersonMap().values()
personList.sort(sortById)
#personList.sort(sortById)
familyList = self.db.getFamilyMap().values()
familyList.sort(sortById)
#familyList.sort(sortById)
sourceList = self.db.getSourceMap().values()
placeList = self.db.getPlaceMap().values()
placeList.sort(sortById)
#placeList.sort(sortById)
objList = self.db.getObjectMap().values()
objList.sort(sortById)
#objList.sort(sortById)
total = len(personList) + len(familyList) + len(placeList) + len(sourceList)

View File

@ -106,7 +106,8 @@ comments = _("GRAMPS (Genealogical Research and Analysis "
#-------------------------------------------------------------------------
picWidth = 275.0
thumbScale = 96.0
indexFile = "data.gramps"
xmlFile = "data.gramps"
zodbFile = "gramps.zodb"
male = _("male")
female = _("female")
unknown = _("unknown")

View File

@ -2364,7 +2364,7 @@
</signal>
<signal>
<name>button_press_event</name>
<handler>on_child_list_button_press_event</handler>
<handler>on_child_list_button_press</handler>
<last_modification_time>Thu, 21 Dec 2000 20:47:47 GMT</last_modification_time>
</signal>
<signal>
@ -2797,7 +2797,7 @@
</signal>
<signal>
<name>button_press_event</name>
<handler>on_source_list_button_press_event</handler>
<handler>on_source_list_button_press</handler>
<last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
</signal>
<columns>5</columns>
@ -7428,7 +7428,24 @@ Unknown
<name>new</name>
<border_width>5</border_width>
<can_focus>True</can_focus>
<label>Create a New Database</label>
<label>Create a New XML Database</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>open</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>zodb</name>
<border_width>5</border_width>
<visible>False</visible>
<can_focus>True</can_focus>
<label>Create a New ZODB Database</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>open</group>

View File

@ -60,7 +60,6 @@ from MediaView import MediaView
from QuestionDialog import QuestionDialog
import ReadXML
import Filter
import const
import Plugins
@ -73,7 +72,14 @@ import EditPerson
import Marriage
import Find
import VersionControl
import WriteXML
from GrampsXML import GrampsXML
try:
from GrampsZODB import GrampsZODB
USE_ZODB = 1
except:
USE_ZODB = 0
#-------------------------------------------------------------------------
#
@ -100,12 +106,11 @@ class Gramps:
self.c_gender = 3
self.c_id = 2
self.c_name = 1
self.c_sort_col = self.c_birth_order
self.c_sort_dir = GTK.SORT_ASCENDING
self.sort_col = 0
self.sort_dir = GTK.SORT_ASCENDING
self.c_scol = self.c_birth_order
self.c_sdir = GTK.SORT_ASCENDING
self.scol = 0
self.sdir = GTK.SORT_ASCENDING
self.id2col = {}
self.alt2col = {}
gtk.rc_parse(const.gtkrcFile)
@ -114,9 +119,12 @@ class Gramps:
"This account is not meant for normal application use.")
gnome.ui.GnomeWarningDialog(msg)
self.database = GrampsDB()
# This will never contain data - It will be replaced by either
# a GrampsXML or GrampsZODB
(self.sort_col,self.sort_dir) = GrampsCfg.get_sort_cols("person",self.sort_col,self.sort_dir)
self.db = GrampsDB()
(self.scol,self.sdir) = GrampsCfg.get_sort_cols("person",self.scol,self.sdir)
GrampsCfg.loadConfig(self.full_update)
self.init_interface()
@ -125,14 +133,14 @@ class Gramps:
self.col_arr = [ self.nameArrow, self.idArrow, self.genderArrow,
self.dateArrow, self.deathArrow]
self.change_sort(self.sort_col,self.sort_dir==GTK.SORT_DESCENDING)
self.set_sort_arrow(self.sort_col,self.sort_dir)
self.change_sort(self.scol,self.sdir==GTK.SORT_DESCENDING)
self.set_sort_arrow(self.scol,self.sdir)
self.database.set_iprefix(GrampsCfg.iprefix)
self.database.set_oprefix(GrampsCfg.oprefix)
self.database.set_fprefix(GrampsCfg.fprefix)
self.database.set_sprefix(GrampsCfg.sprefix)
self.database.set_pprefix(GrampsCfg.pprefix)
self.db.set_iprefix(GrampsCfg.iprefix)
self.db.set_oprefix(GrampsCfg.oprefix)
self.db.set_fprefix(GrampsCfg.fprefix)
self.db.set_sprefix(GrampsCfg.sprefix)
self.db.set_pprefix(GrampsCfg.pprefix)
if arg != None:
if string.upper(arg[-3:]) == "GED":
@ -145,11 +153,11 @@ class Gramps:
import DbPrompter
DbPrompter.DbPrompter(self,0)
if GrampsCfg.autosave_int != 0:
if self.db.need_autosave() and GrampsCfg.autosave_int != 0:
Utils.enable_autosave(self.autosave_database,
GrampsCfg.autosave_int)
self.database.setResearcher(GrampsCfg.get_researcher())
self.db.setResearcher(GrampsCfg.get_researcher())
def init_interface(self):
"""Initializes the GLADE interface, and gets references to the
@ -214,9 +222,9 @@ class Gramps:
self.statusbar,
self.change_active_person,
self.load_person)
self.place_view = PlaceView(self.database,self.gtop,self.update_display)
self.source_view = SourceView(self.database,self.gtop,self.update_display)
self.media_view = MediaView(self.database,self.gtop,self.update_display)
self.place_view = PlaceView(self.db,self.gtop,self.update_display)
self.source_view = SourceView(self.db,self.gtop,self.update_display)
self.media_view = MediaView(self.db,self.gtop,self.update_display)
self.gtop.signal_autoconnect({
"delete_event" : self.delete_event,
@ -237,7 +245,7 @@ class Gramps:
"on_apply_filter_clicked" : self.on_apply_filter_clicked,
"on_arrow_left_clicked" : self.pedigree_view.on_show_child_menu,
"on_canvas1_event" : self.pedigree_view.on_canvas1_event,
"on_child_list_button_press_event" : self.on_child_list_button_press_event,
"on_child_list_button_press" : self.on_child_list_button_press,
"on_child_list_select_row" : self.on_child_list_select_row,
"on_child_list_click_column" : self.on_child_list_click_column,
"on_child_list_row_move" : self.on_child_list_row_move,
@ -246,9 +254,9 @@ class Gramps:
"on_default_person_activate" : self.on_default_person_activate,
"on_delete_parents_clicked" : self.on_delete_parents_clicked,
"on_delete_person_clicked" : self.on_delete_person_clicked,
"on_delete_place_clicked" : self.place_view.on_delete_place_clicked,
"on_delete_source_clicked" : self.source_view.on_delete_source_clicked,
"on_delete_media_clicked" : self.media_view.on_delete_media_clicked,
"on_delete_place_clicked" : self.place_view.on_delete_clicked,
"on_delete_source_clicked" : self.source_view.on_delete_clicked,
"on_delete_media_clicked" : self.media_view.on_delete_clicked,
"on_delete_sp_clicked" : self.on_delete_sp_clicked,
"on_edit_active_person" : self.load_active_person,
"on_edit_selected_people" : self.load_selected_people,
@ -294,7 +302,7 @@ class Gramps:
"on_save_activate" : self.on_save_activate,
"on_save_as_activate" : self.on_save_as_activate,
"on_show_plugin_status" : self.on_show_plugin_status,
"on_source_list_button_press_event" : self.source_view.on_button_press_event,
"on_source_list_button_press" : self.source_view.button_press,
"on_sources_activate" : self.on_sources_activate,
"on_swap_clicked" : self.on_swap_clicked,
"on_tools_clicked" : self.on_tools_clicked,
@ -337,16 +345,16 @@ class Gramps:
"""Display the find box"""
if self.notebook.get_current_page() == 4:
Find.FindPlace(self.place_view.place_list,self.find_goto_place,
self.database.getPlaceMap().values())
self.db.getPlaceMap().values())
elif self.notebook.get_current_page() == 3:
Find.FindSource(self.source_view.source_list,self.find_goto_source,
self.database.getSourceMap().values())
self.db.getSourceMap().values())
elif self.notebook.get_current_page() == 5:
Find.FindMedia(self.media_view.media_list,self.find_goto_media,
self.database.getObjectMap().values())
self.db.getObjectMap().values())
else:
Find.FindPerson(self.person_list,self.find_goto_to,
self.database.getPersonMap().values())
self.db.getPersonMap().values())
def on_findname_activate(self,obj):
"""Display the find box"""
@ -393,7 +401,9 @@ class Gramps:
import MergeData
(p1,x) = self.person_list.get_row_data(self.person_list.selection[0])
(p2,x) = self.person_list.get_row_data(self.person_list.selection[1])
MergeData.MergePeople(self.database,p1,p2,self.merge_update,
p1 = self.db.getPersonMap()[p1]
p2 = self.db.getPersonMap()[p2]
MergeData.MergePeople(self.db,p1,p2,self.merge_update,
self.update_after_edit)
elif page == 4:
self.place_view.merge()
@ -464,7 +474,7 @@ class Gramps:
def delete_family_from(self,person):
person.removeFamily(self.active_family)
self.database.deleteFamily(self.active_family)
self.db.deleteFamily(self.active_family)
flist = self.active_person.getFamilyList()
if len(flist) > 0:
self.active_family = flist[0][0]
@ -477,7 +487,7 @@ class Gramps:
def add_new_new_relationship(self,obj):
import AddSpouse
Utils.destroy_passed_object(self.addornew)
AddSpouse.AddSpouse(self.database,self.active_person,
AddSpouse.AddSpouse(self.db,self.active_person,
self.load_family,self.redisplay_person_list)
def on_add_sp_clicked(self,obj):
@ -493,18 +503,18 @@ class Gramps:
})
self.addornew = top.get_widget('add_or_new')
else:
AddSpouse.AddSpouse(self.database,self.active_person,
AddSpouse.AddSpouse(self.db,self.active_person,
self.load_family,self.redisplay_person_list)
def add_new_choose_spouse(self,obj):
import AddSpouse
Utils.destroy_passed_object(self.addornew)
AddSpouse.SetSpouse(self.database,self.active_person,self.active_family,
AddSpouse.SetSpouse(self.db,self.active_person,self.active_family,
self.load_family, self.redisplay_person_list)
def on_edit_sp_clicked(self,obj):
"""Edit the marriage information for the current family"""
if self.active_person:
Marriage.Marriage(self.active_family,self.database,self.new_after_edit)
Marriage.Marriage(self.active_family,self.db,self.new_after_edit)
def on_delete_sp_clicked(self,obj):
"""Delete the currently selected spouse from the family"""
@ -523,7 +533,7 @@ class Gramps:
if len(self.active_family.getChildList()) == 0:
self.active_person.removeFamily(self.active_family)
self.database.deleteFamily(self.active_family)
self.db.deleteFamily(self.active_family)
if len(self.active_person.getFamilyList()) > 0:
self.load_family(self.active_person.getFamilyList()[0])
else:
@ -568,14 +578,14 @@ class Gramps:
"""Select an existing child to add to the active family"""
import SelectChild
if self.active_person:
SelectChild.SelectChild(self.database,self.active_family,
SelectChild.SelectChild(self.db,self.active_family,
self.active_person,self.load_family)
def on_add_new_child_clicked(self,obj):
"""Create a new child to add to the existing family"""
import SelectChild
if self.active_person:
SelectChild.NewChild(self.database,self.active_family,
SelectChild.NewChild(self.db,self.active_family,
self.active_person,self.update_after_newchild,
self.update_after_edit,
GrampsCfg.lastnamegen)
@ -583,7 +593,7 @@ class Gramps:
def on_choose_parents_clicked(self,obj):
import ChooseParents
if self.active_person:
ChooseParents.ChooseParents(self.database,self.active_person,
ChooseParents.ChooseParents(self.db,self.active_person,
self.active_parents,self.load_family,
self.full_update)
@ -600,7 +610,7 @@ class Gramps:
self.clear_database()
DbPrompter.DbPrompter(self,1)
def clear_database(self):
def clear_database(self,zodb=1):
"""Clear out the database if permission was granted"""
const.personalEvents = const.init_personal_event_list()
const.personalAttributes = const.init_personal_attribute_list()
@ -608,7 +618,15 @@ class Gramps:
const.familyAttributes = const.init_family_attribute_list()
const.familyRelations = const.init_family_relation_list()
self.database.new()
if zodb:
self.db = GrampsZODB()
else:
self.db = GrampsXML()
self.place_view.change_db(self.db)
self.source_view.change_db(self.db)
self.media_view.change_db(self.db)
self.topWindow.set_title("GRAMPS")
self.active_person = None
self.active_father = None
@ -617,7 +635,6 @@ class Gramps:
self.active_child = None
self.active_spouse = None
self.id2col = {}
self.alt2col = {}
Utils.clearModified()
Utils.clear_timer()
@ -636,7 +653,6 @@ class Gramps:
def full_update(self):
"""Brute force display update, updating all the pages"""
self.id2col = {}
self.alt2col = {}
self.person_list.clear()
self.notebook.set_show_tabs(GrampsCfg.usetabs)
self.child_list.set_column_visibility(self.c_details,GrampsCfg.show_detail)
@ -671,12 +687,12 @@ class Gramps:
def on_tools_clicked(self,obj):
if self.active_person:
Plugins.ToolPlugins(self.database,self.active_person,
Plugins.ToolPlugins(self.db,self.active_person,
self.tool_callback)
def on_reports_clicked(self,obj):
if self.active_person:
Plugins.ReportPlugins(self.database,self.active_person)
Plugins.ReportPlugins(self.db,self.active_person)
def on_ok_button1_clicked(self,obj):
@ -692,7 +708,7 @@ class Gramps:
if getoldrev.get_active():
vc = VersionControl.RcsVersionControl(filename)
VersionControl.RevisionSelect(self.database,filename,vc,
VersionControl.RevisionSelect(self.db,filename,vc,
self.load_revision)
else:
self.auto_save_load(filename)
@ -727,12 +743,12 @@ class Gramps:
import ReadGedcom
self.topWindow.set_title("%s - GRAMPS" % filename)
ReadGedcom.importData(self.database,filename)
ReadGedcom.importData(self.db,filename)
self.full_update()
def read_file(self,filename):
base = os.path.basename(filename)
if base == const.indexFile:
if base == const.xmlFile:
filename = os.path.dirname(filename)
elif base == "autosave.gramps":
filename = os.path.dirname(filename)
@ -746,7 +762,7 @@ class Gramps:
if filename[-1] == '/':
filename = filename[:-1]
name = os.path.basename(filename)
self.topWindow.set_title("%s - %s" % (name,_("GRAMPS")))
self.topWindow.set_title("%s - GRAMPS" % name)
else:
self.statusbar.set_status("")
GrampsCfg.save_last_file("")
@ -787,26 +803,26 @@ class Gramps:
return
old_file = filename
filename = filename + os.sep + const.indexFile
filename = "%s/%s" % (filename,self.db.get_base())
try:
WriteXML.exportData(self.database,filename,self.load_progress)
self.db.save(filename,self.load_progress)
except (OSError,IOError), msg:
emsg = _("Could not create %s") % filename + "\n" + str(msg)
gnome.ui.GnomeErrorDialog(emsg)
return
self.database.setSavePath(old_file)
self.db.setSavePath(old_file)
GrampsCfg.save_last_file(old_file)
if GrampsCfg.usevc:
vc = VersionControl.RcsVersionControl(path)
vc.checkin(filename,comment,not GrampsCfg.uncompress)
filename = self.database.getSavePath()
filename = self.db.getSavePath()
if filename[-1] == '/':
filename = filename[:-1]
name = os.path.basename(filename)
self.topWindow.set_title("%s - %s" % (name,_("GRAMPS")))
self.topWindow.set_title("%s - GRAMPS" % name)
self.statusbar.set_status("")
self.statusbar.set_progress(0)
if os.path.exists(autosave):
@ -817,18 +833,18 @@ class Gramps:
def autosave_database(self):
path = self.database.getSavePath()
path = self.db.getSavePath()
if not path:
return
filename = os.path.normpath(path)
Utils.clear_timer()
filename = "%s/autosave.gramps" % (self.database.getSavePath())
filename = "%s/autosave.gramps" % (self.db.getSavePath())
self.statusbar.set_status(_("autosaving..."));
try:
WriteXML.quick_write(self.database,filename,self.quick_progress)
self.db.save(filename,self.quick_progress)
self.statusbar.set_status(_("autosave complete"));
except (IOError,OSError),msg:
self.statusbar.set_status("%s - %s" % (_("autosave failed"),msg))
@ -845,7 +861,7 @@ class Gramps:
else:
for p in self.person_list.selection:
(person,x) = self.person_list.get_row_data(p)
self.load_person(person)
self.load_person(self.db.getPersonMap()[person])
def load_active_person(self,obj):
self.load_person(self.active_person)
@ -864,7 +880,7 @@ class Gramps:
def load_new_person(self,obj):
self.active_person = Person()
EditPerson.EditPerson(self.active_person,self.database,
EditPerson.EditPerson(self.active_person,self.db,
self.new_after_edit)
def on_delete_person_clicked(self,obj):
@ -880,8 +896,8 @@ class Gramps:
gnome.ui.GnomeErrorDialog(msg)
def delete_person_response(self):
personmap = self.database.getPersonMap()
familymap = self.database.getPersonMap()
personmap = self.db.getPersonMap()
familymap = self.db.getPersonMap()
for family in self.active_person.getFamilyList():
if self.active_person.getGender == Person.male:
@ -903,7 +919,7 @@ class Gramps:
if family:
family.removeChild(self.active_person)
del personmap[self.active_person.getId()]
self.db.removePerson(self.active_person.getId())
self.remove_from_person_list(self.active_person)
self.person_list.sort()
self.update_display(0)
@ -912,16 +928,17 @@ class Gramps:
def remove_from_person_list(self,person):
self.person_list.freeze()
if self.id2col.has_key(person):
for id in [self.id2col[person]] + self.alt2col[person]:
pid = person.getId()
if self.id2col.has_key(pid):
for id in self.id2col[pid]:
row = self.person_list.find_row_from_data(id)
self.person_list.remove(row)
del self.id2col[person]
del self.alt2col[person]
del self.id2col[pid]
if row > self.person_list.rows:
(self.active_person,x) = self.person_list.get_row_data(row)
(p,x) = self.person_list.get_row_data(row)
self.active_person = self.db.getPersonMap()[p]
self.person_list.thaw()
def merge_update(self,p1,p2):
@ -939,7 +956,8 @@ class Gramps:
def on_person_list_select_row(self,obj,row,b,c):
if row == obj.selection[0]:
(person,x) = obj.get_row_data(row)
(id,x) = obj.get_row_data(row)
person = self.db.getPersonMap()[id]
self.change_active_person(person)
def on_person_list_click_column(self,obj,column):
@ -964,28 +982,30 @@ class Gramps:
arrow.show()
self.person_list.set_sort_column(self.col_map[column])
self.person_list.set_sort_type(self.sort_dir)
self.person_list.set_sort_type(self.sdir)
self.sort_person_list()
if change:
if self.sort_col == column:
if self.sort_dir == GTK.SORT_DESCENDING:
self.sort_dir = GTK.SORT_ASCENDING
if self.scol == column:
if self.sdir == GTK.SORT_DESCENDING:
self.sdir = GTK.SORT_ASCENDING
arrow.set(GTK.ARROW_DOWN,2)
else:
self.sort_dir = GTK.SORT_DESCENDING
self.sdir = GTK.SORT_DESCENDING
arrow.set(GTK.ARROW_UP,2)
else:
self.sort_dir = GTK.SORT_ASCENDING
self.sdir = GTK.SORT_ASCENDING
arrow.set(GTK.ARROW_DOWN,2)
self.sort_col = column
self.scol = column
if self.id2col.has_key(self.active_person):
data = self.id2col[self.active_person]
if self.active_person:
pid = self.active_person.getId()
if self.id2col.has_key(pid):
data = self.id2col[pid]
row = self.person_list.find_row_from_data(data)
self.person_list.moveto(row)
GrampsCfg.save_sort_cols("person",self.sort_col,self.sort_dir)
GrampsCfg.save_sort_cols("person",self.scol,self.sdir)
def sort_person_list(self):
self.person_list.freeze()
@ -1015,7 +1035,7 @@ class Gramps:
self.goto_active_person()
self.person_list.thaw()
def on_child_list_button_press_event(self,obj,event):
def on_child_list_button_press(self,obj,event):
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
self.load_person(self.active_child)
@ -1023,9 +1043,12 @@ class Gramps:
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
self.load_person(self.active_person)
def goto_active_person(self,):
if self.id2col.has_key(self.active_person):
pos = self.id2col[self.active_person]
def goto_active_person(self):
if not self.active_person:
return
id = self.active_person.getId()
if self.id2col.has_key(id):
pos = self.id2col[id]
column = self.person_list.find_row_from_data(pos)
if column != -1:
self.person_list.unselect_all()
@ -1037,6 +1060,7 @@ class Gramps:
self.person_list.select_row(0,0)
self.person_list.moveto(0)
(person,x) = self.person_list.get_row_data(0)
person = self.db.getPersonMap()[person]
self.change_active_person(person)
def change_active_person(self,person):
@ -1062,7 +1086,8 @@ class Gramps:
return 0
def on_child_list_select_row(self,obj,row,b,c):
self.active_child = obj.get_row_data(row)
id = obj.get_row_data(row)
self.active_child = id #self.db.getPersonMap()[id]
def on_child_list_click_column(self,clist,column):
"""Called when the user selects a column header on the self.person_list
@ -1082,8 +1107,9 @@ class Gramps:
return
self.sort_child_list(clist)
if self.id2col.has_key(self.active_child):
row = clist.find_row_from_data(self.id2col[self.active_child])
if self.active_child and self.id2col.has_key(self.active_child.getId()):
row = clist.find_row_from_data(self.id2col[
self.active_child.getId()])
clist.moveto(row)
def child_change_sort(self,clist,column,arrow):
@ -1093,19 +1119,19 @@ class Gramps:
self.cGenderArrow.hide()
arrow.show()
if self.c_sort_col == column:
if self.c_sort_dir == GTK.SORT_DESCENDING:
self.c_sort_dir = GTK.SORT_ASCENDING
if self.c_scol == column:
if self.c_sdir == GTK.SORT_DESCENDING:
self.c_sdir = GTK.SORT_ASCENDING
arrow.set(GTK.ARROW_DOWN,2)
else:
self.c_sort_dir = GTK.SORT_DESCENDING
self.c_sdir = GTK.SORT_DESCENDING
arrow.set(GTK.ARROW_UP,2)
else:
self.c_sort_dir = GTK.SORT_ASCENDING
self.c_sort_col = column
clist.set_sort_type(self.c_sort_dir)
clist.set_sort_column(self.c_sort_col)
clist.set_reorderable(self.c_sort_col == self.c_birth_order)
self.c_sdir = GTK.SORT_ASCENDING
self.c_scol = column
clist.set_sort_type(self.c_sdir)
clist.set_sort_column(self.c_scol)
clist.set_reorderable(self.c_scol == self.c_birth_order)
def sort_child_list(self,clist):
clist.freeze()
@ -1128,7 +1154,8 @@ class Gramps:
rows = clist.rows
for i in range(0,rows):
clist.set_background(i,(evenbg,oddbg)[i%2])
person = clist.get_row_data(i)
id = clist.get_row_data(i)
person = self.db.getPersonMap()[id]
if (person.getAncestor()):
clist.set_foreground(i,ancestorfg)
else:
@ -1159,7 +1186,7 @@ class Gramps:
# This function deals with ascending order lists. Convert if
# necessary.
if (self.c_sort_dir == GTK.SORT_DESCENDING):
if (self.c_sdir == GTK.SORT_DESCENDING):
clist_order.reverse()
max_index = len(clist_order) - 1
fm = max_index - fm
@ -1189,7 +1216,7 @@ class Gramps:
# Convert the original list back to whatever ordering is being
# used by the clist itself.
if (self.c_sort_dir == GTK.SORT_DESCENDING):
if (self.c_sdir == GTK.SORT_DESCENDING):
clist_order.reverse()
# Update the clist indices so any change of sorting works
@ -1219,7 +1246,7 @@ class Gramps:
def on_revert_activate(self,obj):
if self.database.getSavePath() != "":
if self.db.getSavePath() != "":
msg = _("Do you wish to abandon your changes and "
"revert to the last saved database?")
@ -1238,8 +1265,8 @@ class Gramps:
const.familyAttributes = const.init_family_attribute_list()
const.familyRelations = const.init_family_relation_list()
file = self.database.getSavePath()
self.database.new()
file = self.db.getSavePath()
self.db.new()
self.active_person = None
self.active_father = None
self.active_family = None
@ -1247,7 +1274,6 @@ class Gramps:
self.active_child = None
self.active_spouse = None
self.id2col = {}
self.alt2col = {}
self.read_file(file)
Utils.clearModified()
Utils.clear_timer()
@ -1265,26 +1291,26 @@ class Gramps:
def on_save_activate(self,obj):
"""Saves the file, first prompting for a comment if revision
control needs it"""
if not self.database.getSavePath():
if not self.db.getSavePath():
self.on_save_as_activate(obj)
else:
if GrampsCfg.usevc and GrampsCfg.vc_comment:
self.display_comment_box(self.database.getSavePath())
self.display_comment_box(self.db.getSavePath())
else:
msg = _("No Comment Provided")
self.save_file(self.database.getSavePath(),msg)
self.save_file(self.db.getSavePath(),msg)
def on_save_activate_quit(self):
"""Saves the file, first prompting for a comment if revision
control needs it"""
if not self.database.getSavePath():
if not self.db.getSavePath():
self.on_save_as_activate(None)
else:
if GrampsCfg.usevc and GrampsCfg.vc_comment:
self.display_comment_box(self.database.getSavePath())
self.display_comment_box(self.db.getSavePath())
else:
msg = _("No Comment Provided")
self.save_file(self.database.getSavePath(),msg)
self.save_file(self.db.getSavePath(),msg)
def display_comment_box(self,filename):
"""Displays a dialog box, prompting for a revison control comment"""
@ -1377,9 +1403,9 @@ class Gramps:
def new_after_edit(self,epo,plist):
if epo:
if epo.person.getId() == "":
self.database.addPerson(epo.person)
self.db.addPerson(epo.person)
else:
self.database.addPersonNoMap(epo.person,epo.person.getId())
self.db.addPersonNoMap(epo.person,epo.person.getId())
self.change_active_person(epo.person)
self.redisplay_person_list(epo.person)
for p in plist:
@ -1401,46 +1427,19 @@ class Gramps:
def redisplay_person_list(self,person):
pos = (person,0)
self.id2col[person] = pos
self.alt2col[person] = []
self.id2col[person.getId()] = pos
gname = Utils.phonebook_from_name
bsn = sort.build_sort_name
bsd = sort.build_sort_date
if self.DataFilter.compare(person):
if person.getGender() == Person.male:
gender = const.male
elif person.getGender() == Person.female:
gender = const.female
else:
gender = const.unknown
bday = person.getBirth().getDateObj()
dday = person.getDeath().getDateObj()
name = person.getPrimaryName()
self.person_list.insert(0,[gname(name,0),person.getId(),
gender,bday.getQuoteDate(),
dday.getQuoteDate(),
sort.build_sort_name(name),
sort.build_sort_date(bday),
sort.build_sort_date(dday)])
self.person_list.insert(0,person.getDisplayInfo())
self.person_list.set_row_data(0,pos)
if GrampsCfg.hide_altnames == 0:
for name in person.getAlternateNames():
pos2 = (person,0)
self.alt2col[person].append(pos2)
self.person_list.insert(0,[gname(name,1),person.getId(),
gender,bday.getQuoteDate(),
dday.getQuoteDate(),
sort.build_sort_name(name),
sort.build_sort_date(bday),
sort.build_sort_date(dday)])
self.person_list.set_row_data(0,pos2)
self.sort_person_list()
def load_person(self,person):
if person:
EditPerson.EditPerson(person,self.database,
self.update_after_edit)
EditPerson.EditPerson(person, self.db, self.update_after_edit)
def build_spouse_dropdown(self):
mymap = {}
@ -1669,9 +1668,9 @@ class Gramps:
self.active_child = None
i = 0
self.child_list.set_sort_type(self.c_sort_dir)
self.child_list.set_sort_column(self.c_sort_col)
self.child_list.set_reorderable(self.c_sort_col == self.c_birth_order)
self.child_list.set_sort_type(self.c_sdir)
self.child_list.set_sort_column(self.c_scol)
self.child_list.set_reorderable(self.c_scol == self.c_birth_order)
if family:
if self.active_person == family.getFather():
@ -1679,7 +1678,7 @@ class Gramps:
else:
self.active_spouse = family.getFather()
child_list = family.getChildList()
child_list = list(family.getChildList())
child_list.sort(sort.by_birthdate)
attr = ""
@ -1716,11 +1715,9 @@ class Gramps:
self.child_list.append(["%2d" % (i+1),
GrampsCfg.nameof(child),
child.getId(),
gender,
child.getId(), gender,
Utils.birthday(child),
status,
attr])
status, attr])
self.child_list.set_row_data(i,child)
i=i+1
if i != 0:
@ -1747,57 +1744,50 @@ class Gramps:
gtk.threads_leave()
def post_load(self,name):
self.database.setSavePath(name)
res = self.database.getResearcher()
self.db.setSavePath(name)
res = self.db.getResearcher()
owner = GrampsCfg.get_researcher()
if res.getName() == "" and owner.getName() != "":
self.database.setResearcher(owner)
self.db.setResearcher(owner)
Utils.modified()
self.setup_bookmarks()
mylist = self.database.getPersonEventTypes()
for type in mylist:
ntype = const.display_pevent(type)
if ntype not in const.personalEvents:
const.personalEvents.append(ntype)
mylist = self.database.getFamilyEventTypes()
for type in mylist:
ntype = const.display_fevent(type)
if ntype not in const.marriageEvents:
const.marriageEvents.append(ntype)
mylist = self.database.getPersonAttributeTypes()
for type in mylist:
ntype = const.display_pattr(type)
if ntype not in const.personalAttributes:
const.personalAttributes.append(ntype)
mylist = self.database.getFamilyAttributeTypes()
for type in mylist:
if type not in const.familyAttributes:
const.familyAttributes.append(type)
mylist = self.database.getFamilyRelationTypes()
for type in mylist:
if type not in const.familyRelations:
const.familyRelations.append(type)
# mylist = self.db.getPersonEventTypes()
# for type in mylist:
# ntype = const.display_pevent(type)
# if ntype not in const.personalEvents:
# const.personalEvents.append(ntype)
#
# mylist = self.db.getFamilyEventTypes()
# for type in mylist:
# ntype = const.display_fevent(type)
# if ntype not in const.marriageEvents:
# const.marriageEvents.append(ntype)
#
# mylist = self.db.getPersonAttributeTypes()
# for type in mylist:
# ntype = const.display_pattr(type)
# if ntype not in const.personalAttributes:
# const.personalAttributes.append(ntype)
#
# mylist = self.db.getFamilyAttributeTypes()
# for type in mylist:
# if type not in const.familyAttributes:
# const.familyAttributes.append(type)
#
# mylist = self.db.getFamilyRelationTypes()
# for type in mylist:
# if type not in const.familyRelations:
# const.familyRelations.append(type)
#
GrampsCfg.save_last_file(name)
self.gtop.get_widget("filter").set_text("")
person = self.database.getDefaultPerson()
person = self.db.getDefaultPerson()
if person:
self.active_person = person
for person in self.database.getPersonMap().values():
if self.active_person == None:
self.active_person = person
lastname = person.getPrimaryName().getSurname()
if lastname and lastname not in const.surnames:
const.surnames.append(lastname)
const.surnames.sort()
self.statusbar.set_progress(1.0)
self.full_update()
@ -1805,19 +1795,25 @@ class Gramps:
return 1
def load_database(self,name):
filename = "%s/%s" % (name,const.indexFile)
if ReadXML.loadData(self.database,filename,self.load_progress) == 0:
filename = "%s/%s" % (name,const.xmlFile)
if not os.path.isfile(filename):
filename = "%s/%s" % (name,const.zodbFile)
self.clear_database(1)
else:
self.clear_database(0)
if self.db.load(filename,self.load_progress) == 0:
return 0
return self.post_load(name)
def load_revision(self,f,name,revision):
filename = "%s/%s" % (name,const.indexFile)
if ReadXML.loadRevision(self.database,f,filename,revision,self.load_progress) == 0:
filename = "%s/%s" % (name,self.db.get_base())
if ReadXML.loadRevision(self.db,f,filename,revision,self.load_progress) == 0:
return 0
return self.post_load(name)
def setup_bookmarks(self):
self.bookmarks = Bookmarks.Bookmarks(self.database.getBookmarks(),
self.bookmarks = Bookmarks.Bookmarks(self.db.getBookmarks(),
self.gtop.get_widget("jump_to"),
self.bookmark_callback)
@ -1831,67 +1827,32 @@ class Gramps:
gname = Utils.phonebook_from_name
self.person_list.set_column_visibility(1,GrampsCfg.id_visible)
new_alt2col = {}
bsn = sort.build_sort_name
bsd = sort.build_sort_date
for person in self.database.getPersonMap().values():
i = 0
for key in self.db.getPersonKeys():
i = i + 1
person = self.db.getPersonMap()[key]
if datacomp(person):
if self.id2col.has_key(person):
new_alt2col[person] = self.alt2col[person]
if self.id2col.has_key(key):
continue
pos = (person,0)
self.id2col[person] = pos
new_alt2col[person] = []
pos = (key,0)
self.id2col[key] = pos
if person.getGender() == Person.male:
gender = const.male
elif person.getGender() == Person.female:
gender = const.female
else:
gender = const.unknown
name = person.getPrimaryName()
bday = person.getBirth().getDateObj()
dday = person.getDeath().getDateObj()
sort_bday = bsd(bday)
sort_dday = bsd(dday)
qbday = bday.getQuoteDate()
qdday = dday.getQuoteDate()
pid = person.getId()
values = [gname(name,0), pid, gender, qbday, qdday,
bsn(name), sort_bday, sort_dday ]
self.person_list.insert(0,values)
self.person_list.insert(0,self.db.getPersonDisplay(key))
self.person_list.set_row_data(0,pos)
if GrampsCfg.hide_altnames:
continue
for name in person.getAlternateNames():
pos = (person,1)
new_alt2col[person].append(pos)
values = [gname(name,1), pid, gender, qbday, qdday,
bsn(name), sort_bday, sort_dday]
self.person_list.insert(0,values)
self.person_list.set_row_data(0,pos)
else:
if self.id2col.has_key(person):
pid = self.id2col[person]
del self.id2col[person]
if self.id2col.has_key(key):
del self.id2col[key]
for id in [pid] + self.alt2col[person]:
for id in [key]:
row = self.person_list.find_row_from_data(id)
self.person_list.remove(row)
self.alt2col = new_alt2col
self.person_list.thaw()
self.sort_person_list()
def on_home_clicked(self,obj):
temp = self.database.getDefaultPerson()
temp = self.db.getDefaultPerson()
if temp:
self.change_active_person(temp)
self.update_display(0)
@ -1921,7 +1882,7 @@ class Gramps:
_('Do not change Home Person'))
def set_person(self):
self.database.setDefaultPerson(self.active_person)
self.db.setDefaultPerson(self.active_person)
Utils.modified()
def family_up_clicked(self,obj):
@ -1969,25 +1930,25 @@ class Gramps:
def export_callback(self,obj,plugin_function):
"""Call the export plugin, with the active person and database"""
if self.active_person:
plugin_function(self.database,self.active_person)
plugin_function(self.db,self.active_person)
def import_callback(self,obj,plugin_function):
"""Call the import plugin"""
plugin_function(self.database,self.active_person,self.tool_callback)
self.topWindow.set_title("Gramps - " + self.database.getSavePath())
plugin_function(self.db,self.active_person,self.tool_callback)
self.topWindow.set_title("%s - GRAMPS" % self.db.getSavePath())
def on_preferences_activate(self,obj):
GrampsCfg.display_preferences_box(self.database)
GrampsCfg.display_preferences_box(self.db)
def menu_report(self,obj,task):
"""Call the report plugin selected from the menus"""
if self.active_person:
task(self.database,self.active_person)
task(self.db,self.active_person)
def menu_tools(self,obj,task):
"""Call the tool plugin selected from the menus"""
if self.active_person:
task(self.database,self.active_person,self.tool_callback)
task(self.db,self.active_person,self.tool_callback)
def on_main_key_release_event(self,obj,event):
"""Respond to the insert and delete buttons in the person list"""

View File

@ -81,7 +81,7 @@ class Merge:
self.person_list = database.getPersonMap().values()[:]
base = os.path.dirname(__file__)
self.glade_file = base + os.sep + "merge.glade"
self.glade_file = "%s/%s" % (base,"merge.glade")
top = GladeXML(self.glade_file,"dialog")
my_menu = GtkMenu()

View File

@ -423,7 +423,7 @@ class GedcomParser:
self.update(self.people_obj,str(self.indi_count))
self.indi_count = self.indi_count + 1
self.person = self.db.findPerson(matches[1],self.pmap)
self.added[self.person] = 1
self.added[self.person.getId()] = self.person
self.parse_individual()
elif matches[2] in ["SUBM","SUBN"]:
self.ignore_sub_junk(1)
@ -618,6 +618,7 @@ class GedcomParser:
name.setFirstName(names[0])
if names[2]:
name.setSurname(names[2])
self.db.addSurname(names[2])
if names[4]:
name.setSuffix(names[4])
if name_cnt == 0:
@ -638,6 +639,7 @@ class GedcomParser:
aka.setFirstName(names[0])
if names[2]:
aka.setSurname(names[2])
self.db.addSurname(names[2])
if names[4]:
aka.setSuffix(names[4])
self.person.addAlternateName(aka)
@ -765,7 +767,7 @@ class GedcomParser:
self.person.getPrimaryName().addSourceRef(source_ref)
elif matches[1] == "REFN":
if intRE.match(matches[2]):
self.refn[self.person] = int(matches[2])
self.refn[self.person.getId()] = int(matches[2])
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
self.ignore_sub_junk(2)
elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
@ -1028,6 +1030,7 @@ class GedcomParser:
elif matches[1] == "FAMC":
ord.setFamily(self.db.findFamily(matches[2],self.fmap))
elif matches[1] == "PLAC":
try:
val = matches[2]
if self.placemap.has_key(val):
place = self.placemap[val]
@ -1038,6 +1041,8 @@ class GedcomParser:
self.placemap[val] = place
ord.setPlace(place)
self.ignore_sub_junk(level+1)
except NameError:
print 'please fix the val NameError'
elif matches[1] == "SOUR":
source_ref = SourceRef()
if matches[2] and matches[2][0] != "@":
@ -1432,6 +1437,7 @@ class GedcomParser:
aka.setFirstName(names[0])
if names[2]:
aka.setSurname(names[2])
self.db.addSurname(names[2])
if names[4]:
aka.setSuffix(names[4])
self.person.addAlternateName(aka)
@ -1443,6 +1449,7 @@ class GedcomParser:
pass
elif matches[1] == "SURN":
name.setSurname(matches[2])
self.db.addSurname(matches[2])
elif matches[1] == "TITL":
name.setSuffix(matches[2])
elif matches[1] == "NSFX":
@ -1458,6 +1465,7 @@ class GedcomParser:
else:
name = Name()
name.setSurname(lname[-1])
self.db.addSurname(lname[-1])
name.setFirstName(string.join(lname[0:l-1]))
self.person.addAlternateName(name)
elif matches[1] == "SOUR":
@ -1707,35 +1715,34 @@ class GedcomParser:
def resolve_refns(self):
prefix = self.db.iprefix
pmap = self.db.getPersonMap()
renamed = []
index = 0
new_pmax = self.db.pmapIndex
for person in self.added.keys():
pmap = self.db.getPersonMap()
for pid, person in self.added.items():
index = index + 1
if self.refn.has_key(person):
val = self.refn[person]
if self.refn.has_key(pid):
val = self.refn[pid]
new_key = prefix % val
new_pmax = max(new_pmax,val)
# new ID is not used
if not pmap.has_key(new_key):
del pmap[person.getId()]
pmap[new_key] = person
self.db.removePerson(person.getId())
person.setId(new_key)
self.db.addPersonAs(person)
else:
tp = pmap[new_key]
# same person, just change it
if person == tp:
del pmap[person.getId()]
pmap[new_key] = person
self.db.removePerson(person.getId())
person.setId(new_key)
self.db.addPersonAs(person)
# person currently using it was just added, change it
elif self.added.has_key(tp):
del pmap[person.getId()]
pmap[new_key] = person
elif self.added.has_key(tp.getId()):
self.db.removePerson(person.getId())
person.setId(new_key)
self.db.addPerson(tp)
self.db.addPersonAs(person)
self.db.pmapIndex = new_pmax

View File

@ -44,7 +44,10 @@ def build_sort_name(n):
"""Builds a name from a RelLib.Name instance that is suitable for
use as a sort key in a GtkCList. The name is converted to upper case
to provide for case-insenstive sorting"""
if n.Surname:
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
else:
return "%s" % chr(255)
def build_sort_date(n):
"""Builds a date from a Date.Date instance that is suitable for