diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d8c8e75c1..5ec516315 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,13 @@ +2006-01-06 Don Allingham + * src/DisplayModels.py: don't access db maps directly + * src/PeopleModel.py: don't access db maps directly + * src/FamilyView.py: add gender symbol to primary person + * src/GrampsDb/_GrampsBSDDB.py: provide access functions to avoid + redirect map access + * src/GrampsDb/_GrampsDbBase.py: provide access functions to avoid + redirect map access + * src/GrampsDb/_ReadGedcom.py: don't access db maps directly + 2006-01-06 Alex Roitman * src/GrampsLogger/.cvsignore: Add to CVS. * src/const.py.in: Add directory for the db environment. diff --git a/gramps2/src/DisplayModels.py b/gramps2/src/DisplayModels.py index f2883613d..4459745b3 100644 --- a/gramps2/src/DisplayModels.py +++ b/gramps2/src/DisplayModels.py @@ -157,7 +157,7 @@ class BaseModel(gtk.GenericTreeModel): def on_get_value(self,node,col): try: - return self.fmap[col](self.map[str(node)]) + return self.fmap[col](self.map(str(node))) except: return u'' @@ -283,7 +283,7 @@ class ChildModel(gtk.ListStore): class SourceModel(BaseModel): def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): - self.map = db.source_map + self.map = db.get_raw_source_data self.gen_cursor = db.get_source_cursor self.fmap = [ self.column_title, @@ -346,7 +346,7 @@ class PlaceModel(BaseModel): def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): self.gen_cursor = db.get_place_cursor - self.map = db.place_map + self.map = db.get_raw_place_data self.fmap = [ self.column_name, self.column_id, @@ -455,7 +455,7 @@ class MediaModel(BaseModel): def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): self.gen_cursor = db.get_media_cursor - self.map = db.media_map + self.map = db.get_raw_object_data self.fmap = [ self.column_description, @@ -533,7 +533,7 @@ class EventModel(BaseModel): def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): self.gen_cursor = db.get_event_cursor - self.map = db.event_map + self.map = db.get_raw_event_data self.fmap = [ self.column_description, @@ -619,7 +619,7 @@ class RepositoryModel(BaseModel): def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): self.gen_cursor = db.get_repository_cursor self.get_handles = db.get_repository_handles - self.map = db.repository_map + self.map = db.get_raw_repository_data self.fmap = [ self.column_name, self.column_id, diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index 7efb780a5..090478ba0 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -32,6 +32,12 @@ import ImgManip import ReportUtils import GrampsKeys +_GenderCode = { + RelLib.Person.MALE : u'\u2642', + RelLib.Person.FEMALE : u'\u2640', + RelLib.Person.UNKNOWN : u'\u2650', + } + class LinkLabel(gtk.EventBox): def __init__(self,label,func,handle): @@ -40,7 +46,7 @@ class LinkLabel(gtk.EventBox): self.gender = label[1] text = '%s' % self.orig_text if label[1]: - text += u" %s" % label[1] + text += u' %s' % label[1] self.label = gtk.Label(text) self.label.set_use_markup(True) @@ -198,14 +204,10 @@ class FamilyView(PageView.PersonNavView): if handle: p = self.dbstate.db.get_person_from_handle(handle) name = NameDisplay.displayer.display(p) - gender = "" if use_gender: - if p.gender == RelLib.Person.MALE: - gender = u' \u2642' - elif p.gender == RelLib.Person.FEMALE: - gender = u" \u2640" - else: - gender = u" \u2650" + gender = _GenderCode[p.gender] + else: + gender = "" return (name,gender) else: return (_(u"Unknown"),"") @@ -241,7 +243,8 @@ class FamilyView(PageView.PersonNavView): # name and edit button name = NameDisplay.displayer.display(person) - text = '%s' % cgi.escape(name) + text = '%s %s' % (cgi.escape(name), + _GenderCode[person.gender]) label = MarkupLabel(text) button = IconButton(self.edit_button_press,person.handle) diff --git a/gramps2/src/GrampsDb/_GrampsBSDDB.py b/gramps2/src/GrampsDb/_GrampsBSDDB.py index a6b183708..ac40e2143 100644 --- a/gramps2/src/GrampsDb/_GrampsBSDDB.py +++ b/gramps2/src/GrampsDb/_GrampsBSDDB.py @@ -155,6 +155,69 @@ class GrampsBSDDB(GrampsDbBase): def get_repository_cursor(self): return GrampsBSDDBCursor(self.repository_map,self.txn) + def has_person_handle(self,handle): + """ + returns True if the handle exists in the current Person database. + """ + return self.person_map.get(str(handle),txn=self.txn) != None + + def has_family_handle(self,handle): + """ + returns True if the handle exists in the current Family database. + """ + return self.family_map.get(str(handle),txn=self.txn) != None + + def has_object_handle(self,handle): + """ + returns True if the handle exists in the current MediaObjectdatabase. + """ + return self.media_map.get(str(handle),txn=self.txn) != None + + def has_repository_handle(self,handle): + """ + returns True if the handle exists in the current Repository database. + """ + return self.repository_map.get(str(handle),txn=self.txn) != None + + def has_event_handle(self,handle): + """ + returns True if the handle exists in the current Repository database. + """ + return self.event_map.get(str(handle),txn=self.txn) != None + + def has_place_handle(self,handle): + """ + returns True if the handle exists in the current Repository database. + """ + return self.place_map.get(str(handle),txn=self.txn) != None + + def has_source_handle(self,handle): + """ + returns True if the handle exists in the current Repository database. + """ + return self.source_map.get(str(handle),txn=self.txn) != None + + def get_raw_person_data(self,handle): + return self.person_map.get(str(handle),txn=self.txn) + + def get_raw_family_data(self,handle): + return self.family_map.get(str(handle),txn=self.txn) + + def get_raw_object_data(self,handle): + return self.media_map.get(str(handle),txn=self.txn) + + def get_raw_place_data(self,handle): + return self.place_map.get(str(handle),txn=self.txn) + + def get_raw_event_data(self,handle): + return self.event_map.get(str(handle),txn=self.txn) + + def get_raw_source_data(self,handle): + return self.source_map.get(str(handle),txn=self.txn) + + def get_raw_repository_data(self,handle): + return self.repository_map.get(str(handle),txn=self.txn) + # cursors for lookups in the reference_map for back reference # lookups. The reference_map has three indexes: # the main index: a tuple of (primary_handle,referenced_handle) @@ -759,7 +822,7 @@ class GrampsBSDDB(GrampsDbBase): if data: obj = class_init() obj.unserialize(cPickle.loads(data)) - return person + return obj else: return None diff --git a/gramps2/src/GrampsDb/_GrampsDbBase.py b/gramps2/src/GrampsDb/_GrampsDbBase.py index c83229b6c..b227b9b44 100644 --- a/gramps2/src/GrampsDb/_GrampsDbBase.py +++ b/gramps2/src/GrampsDb/_GrampsDbBase.py @@ -1370,12 +1370,51 @@ class GrampsDbBase(GrampsDBCallback): self._do_remove_object(handle,transaction,self.repository_map, REPOSITORY_KEY, transaction.repository_del) + def get_raw_person_data(self,handle): + return self.person_map.get(str(handle)) + + def get_raw_family_data(self,handle): + return self.family_map.get(str(handle)) + + def get_raw_object_data(self,handle): + return self.media_map.get(str(handle)) + + def get_raw_place_data(self,handle): + return self.place_map.get(str(handle)) + + def get_raw_event_data(self,handle): + return self.event_map.get(str(handle)) + + def get_raw_source_data(self,handle): + return self.source_map.get(str(handle)) + + def get_raw_repository_data(self,handle): + return self.repository_map.get(str(handle)) + def has_person_handle(self,handle): """ returns True if the handle exists in the current Person database. """ return self.person_map.has_key(str(handle)) + def has_event_handle(self,handle): + """ + returns True if the handle exists in the current Event database. + """ + return self.event_map.has_key(str(handle)) + + def has_source_handle(self,handle): + """ + returns True if the handle exists in the current Source database. + """ + return self.source_map.has_key(str(handle)) + + def has_place_handle(self,handle): + """ + returns True if the handle exists in the current Place database. + """ + return self.place_map.has_key(str(handle)) + def has_family_handle(self,handle): """ returns True if the handle exists in the current Family database. diff --git a/gramps2/src/GrampsDb/_ReadGedcom.py b/gramps2/src/GrampsDb/_ReadGedcom.py index 02b8c6f0c..c4b2a8f06 100644 --- a/gramps2/src/GrampsDb/_ReadGedcom.py +++ b/gramps2/src/GrampsDb/_ReadGedcom.py @@ -778,8 +778,8 @@ class GedcomParser: def find_or_create_person(self,gramps_id): person = RelLib.Person() intid = self.gid2id.get(gramps_id) - if self.db.person_map.has_key(intid): - person.unserialize(self.db.person_map.get(intid)) + if self.db.has_person_handle(intid): + person.unserialize(self.db.get_raw_person_data(intid)) else: intid = self.find_person_handle(gramps_id) person.set_handle(intid) @@ -796,8 +796,8 @@ class GedcomParser: def find_or_create_family(self,gramps_id): family = RelLib.Family() intid = self.fid2id.get(gramps_id) - if self.db.family_map.has_key(intid): - family.unserialize(self.db.family_map.get(intid)) + if self.db.has_family_handle(intid): + family.unserialize(self.db.get_raw_family_data(intid)) else: intid = self.find_family_handle(gramps_id) family.set_handle(intid) @@ -814,8 +814,8 @@ class GedcomParser: def find_or_create_source(self,gramps_id): source = RelLib.Source() intid = self.sid2id.get(gramps_id) - if self.db.source_map.has_key(intid): - source.unserialize(self.db.source_map.get(intid)) + if self.db.has_source_handle(intid): + source.unserialize(self.db.get_raw_source_data(intid)) else: intid = create_id() source.set_handle(intid) @@ -846,8 +846,8 @@ class GedcomParser: else: pname = title - if self.db.place_map.has_key(intid): - place.unserialize(self.db.place_map.get(intid)) + if self.db.has_place_handle(intid): + place.unserialize(self.db.get_raw_place_data(intid)) else: intid = create_id() place.set_handle(intid) diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 9ddc69a82..85df80dc5 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -236,7 +236,7 @@ class PeopleModel(gtk.GenericTreeModel): # return values for 'data' row, calling a function # according to column_defs table try: - return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.db.person_map[str(node)],node) + return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.db.get_raw_person_data(str(node)),node) except: print "".join(traceback.format_exception(*sys.exc_info())) return u'error'