2006-09-09 Don Allingham <don@gramps-project.org>

* src/GrampsDb/_ReadXML.py: remove commented out code
	* src/Editors/_EditEvent.py: handle overwriting of date text
	* src/RelLib/_DateBase.py: allow optional dropping of date text on
	serialization
	* src/RelLib/_Date.py: allow optional dropping of date text on
	serialization
	* src/RelLib/_Event.py: allow optional dropping of date text on
	serialization



svn: r7306
This commit is contained in:
Don Allingham
2006-09-09 17:10:13 +00:00
parent 52b44be3aa
commit 76cce7e656
8 changed files with 64 additions and 73 deletions

View File

@@ -224,6 +224,30 @@ class EditEvent(EditPrimary):
self.callback(self.obj)
self.close()
def data_has_changed(self):
"""
A date comparison can fail incorrectly because we have made the
decision to store entered text in the date. However, there is no
entered date when importing from a XML file, so we can get an
incorrect fail.
"""
if self.db.readonly:
return False
elif self.obj.handle:
orig = self.get_from_handle(self.obj.handle)
if orig:
cmp_obj = orig
else:
cmp_obj = self.empty_object()
return cmp(cmp_obj.serialize(True)[1:],
self.obj.serialize(True)[1:]) != 0
else:
cmp_obj = self.empty_object()
return cmp(cmp_obj.serialize(True)[1:],
self.obj.serialize()[1:]) != 0
class EditPersonEvent(EditEvent):
def __init__(self, event, dbstate, uistate, track=[], callback=None):

View File

@@ -162,11 +162,6 @@ def importData(database, filename, callback=None,cl=0,use_trans=False):
ErrorDialog(_("Error reading %s") % filename,
_("The file is probably either corrupt or not a valid GRAMPS database."))
return
# except:
# if cl:
# import traceback
# traceback.print_exc()
# os._exit(1)
xml_file.close()

View File

@@ -135,12 +135,17 @@ class Date:
self.text = u""
self.sortval = 0
def serialize(self):
def serialize(self, no_text_date=False):
"""
Convert to a series of tuples for data storage
"""
if no_text_date:
text = u''
else:
text = self.text
return (self.calendar, self.modifier, self.quality,
self.dateval, self.text, self.sortval)
self.dateval, text, self.sortval)
def unserialize(self, data):
"""

View File

@@ -53,11 +53,11 @@ class DateBase:
else:
self.date = Date()
def serialize(self):
def serialize(self, no_text_date=False):
if self.date == None or (self.date.is_empty() and not self.date.text):
date = None
else:
date = self.date.serialize()
date = self.date.serialize(no_text_date)
return date
def unserialize(self,data):

View File

@@ -76,7 +76,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
self.description = ""
self.type = EventType()
def serialize(self):
def serialize(self, no_text_date = False):
"""
Converts the data held in the event to a Python tuple that
represents all the data elements. This method is used to convert
@@ -93,7 +93,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
@rtype: tuple
"""
return (self.handle, self.gramps_id, self.type.serialize(),
DateBase.serialize(self),
DateBase.serialize(self, no_text_date),
self.description, self.place,
SourceBase.serialize(self),
NoteBase.serialize(self),