* 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 svn: r5689
This commit is contained in:
parent
b7d493d92a
commit
636d0df973
@ -1,3 +1,13 @@
|
||||
2006-01-06 Don Allingham <don@gramps-project.org>
|
||||
* 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 <shura@gramps-project.org>
|
||||
* src/GrampsLogger/.cvsignore: Add to CVS.
|
||||
* src/const.py.in: Add directory for the db environment.
|
||||
|
@ -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,
|
||||
|
@ -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 = '<span underline="single">%s</span>' % 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' <span weight="bold">\u2642</span>'
|
||||
elif p.gender == RelLib.Person.FEMALE:
|
||||
gender = u" \u2640"
|
||||
gender = _GenderCode[p.gender]
|
||||
else:
|
||||
gender = u" \u2650"
|
||||
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 = '<span size="larger" weight="bold">%s</span>' % cgi.escape(name)
|
||||
text = '<span size="larger" weight="bold">%s %s</span>' % (cgi.escape(name),
|
||||
_GenderCode[person.gender])
|
||||
label = MarkupLabel(text)
|
||||
button = IconButton(self.edit_button_press,person.handle)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user