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

View File

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

View File

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

View File

@ -57,7 +57,7 @@ class NameEditor:
self.type_field = self.top.get_widget("name_type") self.type_field = self.top.get_widget("name_type")
self.note_field = self.top.get_widget("alt_note") self.note_field = self.top.get_widget("alt_note")
slist = self.top.get_widget("alt_surname_list") 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") self.priv = self.top.get_widget("priv")
types = const.NameTypesMap.keys() types = const.NameTypesMap.keys()
@ -138,9 +138,7 @@ class NameEditor:
if self.name.getSurname() != last: if self.name.getSurname() != last:
self.name.setSurname(last) self.name.setSurname(last)
if last not in const.surnames: self.parent.db.addSurname(last)
const.surnames.append(last)
const.surnames.sort()
self.parent.lists_changed = 1 self.parent.lists_changed = 1
if self.name.getSuffix() != suffix: 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_column(self.sort_map[self.sort_col])
self.place_list.set_sort_type(self.sort_dir) self.place_list.set_sort_type(self.sort_dir)
def change_db(self,db):
self.db = db
def load_places(self): def load_places(self):
"""Rebuilds the entire place view. This can be very time consuming """Rebuilds the entire place view. This can be very time consuming
on large databases, and should only be called when absolutely on large databases, and should only be called when absolutely
@ -105,23 +108,12 @@ class PlaceView:
self.place_list.freeze() self.place_list.freeze()
self.place_list.clear() self.place_list.clear()
self.place_list.set_column_visibility(1,GrampsCfg.id_visible) self.place_list.set_column_visibility(1,GrampsCfg.id_visible)
index = 0 index = 0
u = string.upper for key in self.db.getPlaceKeys():
for src in self.db.getPlaceMap().values(): src = self.db.getPlaceMap()[key]
title = src.get_title() self.place_list.append(src.getDisplayInfo())
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)])
self.place_list.set_row_data(index,src) self.place_list.set_row_data(index,src)
index = index + 1 index = index + 1
@ -194,18 +186,7 @@ class PlaceView:
obj.thaw() obj.thaw()
def insert_place(self,place): def insert_place(self,place):
title = place.get_title() self.place_list.append(place.getDisplayInfo())
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.set_row_data(self.place_list.rows-1,place) self.place_list.set_row_data(self.place_list.rows-1,place)
def new_place_after_edit(self,place): def new_place_after_edit(self,place):
@ -231,7 +212,7 @@ class PlaceView:
self.place_list.select_row(row,0) self.place_list.select_row(row,0)
self.place_list.moveto(row) self.place_list.moveto(row)
def on_delete_place_clicked(self,obj): def on_delete_clicked(self,obj):
if len(obj.selection) == 0: if len(obj.selection) == 0:
return return
elif len(obj.selection) > 1: 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("given"))
self.window.editable_enters(self.xml.get_widget("surname")) self.window.editable_enters(self.xml.get_widget("surname"))
self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"), self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"),
const.surnames) self.db.getSurnames())
def close(self,obj): def close(self,obj):
surname = self.xml.get_widget("surname").get_text() surname = self.xml.get_widget("surname").get_text()

View File

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

View File

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

View File

@ -429,20 +429,6 @@ def thumb_path(dir,mobj):
else: else:
return find_icon(type) 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 # 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())) date = string.split(time.ctime(time.time()))
owner = self.db.getResearcher() owner = self.db.getResearcher()
personList = self.db.getPersonMap().values() personList = self.db.getPersonMap().values()
personList.sort(sortById) #personList.sort(sortById)
familyList = self.db.getFamilyMap().values() familyList = self.db.getFamilyMap().values()
familyList.sort(sortById) #familyList.sort(sortById)
sourceList = self.db.getSourceMap().values() sourceList = self.db.getSourceMap().values()
placeList = self.db.getPlaceMap().values() placeList = self.db.getPlaceMap().values()
placeList.sort(sortById) #placeList.sort(sortById)
objList = self.db.getObjectMap().values() objList = self.db.getObjectMap().values()
objList.sort(sortById) #objList.sort(sortById)
total = len(personList) + len(familyList) + len(placeList) + len(sourceList) total = len(personList) + len(familyList) + len(placeList) + len(sourceList)

View File

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

View File

@ -2364,7 +2364,7 @@
</signal> </signal>
<signal> <signal>
<name>button_press_event</name> <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> <last_modification_time>Thu, 21 Dec 2000 20:47:47 GMT</last_modification_time>
</signal> </signal>
<signal> <signal>
@ -2797,7 +2797,7 @@
</signal> </signal>
<signal> <signal>
<name>button_press_event</name> <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> <last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
</signal> </signal>
<columns>5</columns> <columns>5</columns>
@ -7428,7 +7428,24 @@ Unknown
<name>new</name> <name>new</name>
<border_width>5</border_width> <border_width>5</border_width>
<can_focus>True</can_focus> <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> <active>False</active>
<draw_indicator>True</draw_indicator> <draw_indicator>True</draw_indicator>
<group>open</group> <group>open</group>

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@ class Merge:
self.person_list = database.getPersonMap().values()[:] self.person_list = database.getPersonMap().values()[:]
base = os.path.dirname(__file__) 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") top = GladeXML(self.glade_file,"dialog")
my_menu = GtkMenu() my_menu = GtkMenu()

View File

@ -112,7 +112,7 @@ def importData(database, filename):
# add some checking here # add some checking here
glade_file = "%s/gedcomimport.glade" % os.path.dirname(__file__) glade_file = "%s/gedcomimport.glade" % os.path.dirname(__file__)
statusTop = libglade.GladeXML(glade_file,"status") statusTop = libglade.GladeXML(glade_file,"status")
statusWindow = statusTop.get_widget("status") statusWindow = statusTop.get_widget("status")
statusTop.get_widget("close").set_sensitive(0) statusTop.get_widget("close").set_sensitive(0)
@ -423,7 +423,7 @@ class GedcomParser:
self.update(self.people_obj,str(self.indi_count)) self.update(self.people_obj,str(self.indi_count))
self.indi_count = self.indi_count + 1 self.indi_count = self.indi_count + 1
self.person = self.db.findPerson(matches[1],self.pmap) self.person = self.db.findPerson(matches[1],self.pmap)
self.added[self.person] = 1 self.added[self.person.getId()] = self.person
self.parse_individual() self.parse_individual()
elif matches[2] in ["SUBM","SUBN"]: elif matches[2] in ["SUBM","SUBN"]:
self.ignore_sub_junk(1) self.ignore_sub_junk(1)
@ -618,6 +618,7 @@ class GedcomParser:
name.setFirstName(names[0]) name.setFirstName(names[0])
if names[2]: if names[2]:
name.setSurname(names[2]) name.setSurname(names[2])
self.db.addSurname(names[2])
if names[4]: if names[4]:
name.setSuffix(names[4]) name.setSuffix(names[4])
if name_cnt == 0: if name_cnt == 0:
@ -638,6 +639,7 @@ class GedcomParser:
aka.setFirstName(names[0]) aka.setFirstName(names[0])
if names[2]: if names[2]:
aka.setSurname(names[2]) aka.setSurname(names[2])
self.db.addSurname(names[2])
if names[4]: if names[4]:
aka.setSuffix(names[4]) aka.setSuffix(names[4])
self.person.addAlternateName(aka) self.person.addAlternateName(aka)
@ -765,7 +767,7 @@ class GedcomParser:
self.person.getPrimaryName().addSourceRef(source_ref) self.person.getPrimaryName().addSourceRef(source_ref)
elif matches[1] == "REFN": elif matches[1] == "REFN":
if intRE.match(matches[2]): 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"]: elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
self.ignore_sub_junk(2) self.ignore_sub_junk(2)
elif matches[1] in ["ANCI","DESI","RIN","RFN"]: elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
@ -1028,6 +1030,7 @@ class GedcomParser:
elif matches[1] == "FAMC": elif matches[1] == "FAMC":
ord.setFamily(self.db.findFamily(matches[2],self.fmap)) ord.setFamily(self.db.findFamily(matches[2],self.fmap))
elif matches[1] == "PLAC": elif matches[1] == "PLAC":
try:
val = matches[2] val = matches[2]
if self.placemap.has_key(val): if self.placemap.has_key(val):
place = self.placemap[val] place = self.placemap[val]
@ -1038,6 +1041,8 @@ class GedcomParser:
self.placemap[val] = place self.placemap[val] = place
ord.setPlace(place) ord.setPlace(place)
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
except NameError:
print 'please fix the val NameError'
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
source_ref = SourceRef() source_ref = SourceRef()
if matches[2] and matches[2][0] != "@": if matches[2] and matches[2][0] != "@":
@ -1432,6 +1437,7 @@ class GedcomParser:
aka.setFirstName(names[0]) aka.setFirstName(names[0])
if names[2]: if names[2]:
aka.setSurname(names[2]) aka.setSurname(names[2])
self.db.addSurname(names[2])
if names[4]: if names[4]:
aka.setSuffix(names[4]) aka.setSuffix(names[4])
self.person.addAlternateName(aka) self.person.addAlternateName(aka)
@ -1443,6 +1449,7 @@ class GedcomParser:
pass pass
elif matches[1] == "SURN": elif matches[1] == "SURN":
name.setSurname(matches[2]) name.setSurname(matches[2])
self.db.addSurname(matches[2])
elif matches[1] == "TITL": elif matches[1] == "TITL":
name.setSuffix(matches[2]) name.setSuffix(matches[2])
elif matches[1] == "NSFX": elif matches[1] == "NSFX":
@ -1458,6 +1465,7 @@ class GedcomParser:
else: else:
name = Name() name = Name()
name.setSurname(lname[-1]) name.setSurname(lname[-1])
self.db.addSurname(lname[-1])
name.setFirstName(string.join(lname[0:l-1])) name.setFirstName(string.join(lname[0:l-1]))
self.person.addAlternateName(name) self.person.addAlternateName(name)
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
@ -1707,35 +1715,34 @@ class GedcomParser:
def resolve_refns(self): def resolve_refns(self):
prefix = self.db.iprefix prefix = self.db.iprefix
pmap = self.db.getPersonMap()
renamed = [] renamed = []
index = 0 index = 0
new_pmax = self.db.pmapIndex 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 index = index + 1
if self.refn.has_key(person): if self.refn.has_key(pid):
val = self.refn[person] val = self.refn[pid]
new_key = prefix % val new_key = prefix % val
new_pmax = max(new_pmax,val) new_pmax = max(new_pmax,val)
# new ID is not used # new ID is not used
if not pmap.has_key(new_key): if not pmap.has_key(new_key):
del pmap[person.getId()] self.db.removePerson(person.getId())
pmap[new_key] = person
person.setId(new_key) person.setId(new_key)
self.db.addPersonAs(person)
else: else:
tp = pmap[new_key] tp = pmap[new_key]
# same person, just change it # same person, just change it
if person == tp: if person == tp:
del pmap[person.getId()] self.db.removePerson(person.getId())
pmap[new_key] = person
person.setId(new_key) person.setId(new_key)
self.db.addPersonAs(person)
# person currently using it was just added, change it # person currently using it was just added, change it
elif self.added.has_key(tp): elif self.added.has_key(tp.getId()):
del pmap[person.getId()] self.db.removePerson(person.getId())
pmap[new_key] = person
person.setId(new_key) person.setId(new_key)
self.db.addPerson(tp) self.db.addPersonAs(person)
self.db.pmapIndex = new_pmax 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 """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 use as a sort key in a GtkCList. The name is converted to upper case
to provide for case-insenstive sorting""" to provide for case-insenstive sorting"""
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix)) 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): def build_sort_date(n):
"""Builds a date from a Date.Date instance that is suitable for """Builds a date from a Date.Date instance that is suitable for