diff --git a/src/Simple/_SimpleAccess.py b/src/Simple/_SimpleAccess.py
index 284c897d0..efc954448 100644
--- a/src/Simple/_SimpleAccess.py
+++ b/src/Simple/_SimpleAccess.py
@@ -27,6 +27,7 @@ from types import NoneType
import gen.lib
import DateHandler
import Utils
+import gen.utils
from gen.display.name import displayer as name_displayer
from gen.lib import EventType
@@ -515,6 +516,21 @@ class SimpleAccess(object):
person = self.dbase.get_person_from_handle(person)
return self.__event_date_obj(person, gen.lib.Person.get_birth_ref)
+
+ def birth_or_fallback(self, person):
+ """
+ Return the date of the person's birth or fallback event.
+
+ @param person: Person object
+ @type person: L{gen.lib.Person}
+ @return: Returns the date when the person's birth or fallback.
+ @rtype: L{gen.lib.Date}
+ """
+ if type(person) in [str, unicode]:
+ person = self.dbase.get_person_from_handle(person)
+ return gen.utils.get_birth_or_fallback(self.dbase,
+ person, "%s").date
+
def birth_place(self, person):
"""
Return a string indicating the place of the person's birth.
@@ -554,6 +570,20 @@ class SimpleAccess(object):
person = self.dbase.get_person_from_handle(person)
return self.__event_date_obj(person, gen.lib.Person.get_death_ref)
+ def death_or_fallback(self, person):
+ """
+ Return the date of the person's death or fallback event.
+
+ @param person: Person object
+ @type person: L{gen.lib.Person}
+ @return: Returns the date of the person's death or fallback.
+ @rtype: L{gen.lib.Date}
+ """
+ if type(person) in [str, unicode]:
+ person = self.dbase.get_person_from_handle(person)
+ return gen.utils.get_death_or_fallback(self.dbase,
+ person, "%s").date
+
def death_place(self, person):
"""
Return a string indicating the place of the person's death.
diff --git a/src/Simple/_SimpleTable.py b/src/Simple/_SimpleTable.py
index a882e2b9b..17cbda07b 100644
--- a/src/Simple/_SimpleTable.py
+++ b/src/Simple/_SimpleTable.py
@@ -285,6 +285,9 @@ class SimpleTable(object):
text = DateHandler.displayer.display(item)
retval.append(text)
if item.get_valid():
+ if item.format:
+ self.set_cell_markup(col, row,
+ item.format % cgi.escape(text))
self.row_sort_val(col, item.sortval)
else:
# sort before others:
@@ -292,7 +295,7 @@ class SimpleTable(object):
# give formatted version:
invalid_date_format = config.get('preferences.invalid-date-format')
self.set_cell_markup(col, row,
- invalid_date_format % text)
+ invalid_date_format % cgi.escape(text))
if (self.__link_col == col or link is None):
link = ('Date', item)
elif isinstance(item, gen.lib.Span):
diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py
index e353902e8..7e8471139 100644
--- a/src/gen/lib/date.py
+++ b/src/gen/lib/date.py
@@ -683,6 +683,7 @@ class Date(object):
pass # source is ok
else:
raise AttributeError, "invalid args to Date: %s" % source
+ self.format = None
#### ok, process either date or tuple
if isinstance(source, tuple):
self.calendar = Date.CAL_GREGORIAN
diff --git a/src/gen/utils/fallback.py b/src/gen/utils/fallback.py
index 7a5a73104..77b1299ba 100644
--- a/src/gen/utils/fallback.py
+++ b/src/gen/utils/fallback.py
@@ -24,7 +24,7 @@
Functional database interface for getting events, or fallback events.
"""
-def get_birth_or_fallback(db, person):
+def get_birth_or_fallback(db, person, format=None):
"""
Get BIRTH event from a person, or fallback to an event around
the time of birth.
@@ -41,10 +41,12 @@ def get_birth_or_fallback(db, person):
if (event
and event.type.is_birth_fallback()
and event_ref.role.is_primary()):
+ if format:
+ event.date.format = format
return event
return None
-def get_death_or_fallback(db, person):
+def get_death_or_fallback(db, person, format=None):
"""
Get a DEATH event from a person, or fallback to an
event around the time of death.
@@ -61,5 +63,8 @@ def get_death_or_fallback(db, person):
if (event
and event.type.is_death_fallback()
and event_ref.role.is_primary()):
+ if format:
+ event.date.format = format
return event
return None
+
diff --git a/src/plugins/quickview/FilterByName.py b/src/plugins/quickview/FilterByName.py
index 278e6af62..b5c25fe2d 100644
--- a/src/plugins/quickview/FilterByName.py
+++ b/src/plugins/quickview/FilterByName.py
@@ -76,28 +76,28 @@ def run(database, document, filter_name, *args, **kwargs):
if (filter_name == 'all people'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'males'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
if person.gender == Person.MALE:
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'females'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
if person.gender == Person.FEMALE:
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'people with unknown gender'):
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
for person in database.iter_people():
if person.gender not in [Person.FEMALE, Person.MALE]:
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'people with incomplete names'):
@@ -105,7 +105,7 @@ def run(database, document, filter_name, *args, **kwargs):
for person in database.iter_people():
for name in [person.get_primary_name()] + person.get_alternate_names():
if name.get_group_name() == "" or name.get_first_name() == "":
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'people with missing birth dates'):
@@ -125,7 +125,7 @@ def run(database, document, filter_name, *args, **kwargs):
for person in database.iter_people():
if ((not person.get_main_parents_family_handle()) and
(not len(person.get_family_handle_list()))):
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'all families'):
@@ -193,7 +193,7 @@ def run(database, document, filter_name, *args, **kwargs):
handles = kwargs["handles"]
for person_handle in handles:
person = database.get_person_from_handle(person_handle)
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
else:
diff --git a/src/plugins/quickview/SameSurnames.py b/src/plugins/quickview/SameSurnames.py
index dc5cb80c0..96da9ada7 100644
--- a/src/plugins/quickview/SameSurnames.py
+++ b/src/plugins/quickview/SameSurnames.py
@@ -118,7 +118,7 @@ def run(database, document, person):
matches = 0
for person_handle in people:
person = database.get_person_from_handle(person_handle)
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
@@ -159,7 +159,7 @@ def run_given(database, document, person):
matches = 0
for person_handle in people:
person = database.get_person_from_handle(person_handle)
- stab.row(person, sdb.birth_date_obj(person),
+ stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
diff --git a/src/plugins/quickview/lineage.py b/src/plugins/quickview/lineage.py
index da901770b..fc8573af7 100644
--- a/src/plugins/quickview/lineage.py
+++ b/src/plugins/quickview/lineage.py
@@ -112,8 +112,8 @@ def make_details(gender, person, sa, sd, database, stab) :
rem_str = ""
while person:
person_handle = person.handle
- stab.row(person, sa.birth_date_obj(person),
- sa.death_date_obj(person), rem_str)
+ stab.row(person, sa.birth_or_fallback(person),
+ sa.death_or_fallback(person), rem_str)
#if rem_str:
# sd.paragraph(__FMT_REM % (_("Remark"), rem_str))
diff --git a/src/plugins/quickview/siblings.py b/src/plugins/quickview/siblings.py
index e4bede8d8..5083fc7b8 100644
--- a/src/plugins/quickview/siblings.py
+++ b/src/plugins/quickview/siblings.py
@@ -61,6 +61,6 @@ def run(database, document, person):
# pass row the child object to make link:
stab.row(child,
sdb.gender(child),
- sdb.birth_date_obj(child),
+ sdb.birth_or_fallback(child),
rel_str)
stab.write(sdoc)