diff --git a/ChangeLog b/ChangeLog index 9ae58242d..761cd17c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,12 @@ * src/RelLib/Makefile.am: Ship new files; * src/RelLib/ various files: add more files. + * src/GrampsBSDDB.py (gramps_upgrade_9): Upgrade witness list in + the old Event object. + * src/RelLib/_Event.py: Remove external witnesses altogether. + * src/RelLib/_Witness.py: Make even emptier (needed for upgrade only). + * src/RelLib/__init__.py: Expose Witness (needed for upgrade only). + 2005-12-20 Richard Taylor * src/RelLib/_helper.py: removed get_backlink_handles * test/RelLib_Test.py: removed test for get_backlink_handles diff --git a/src/GrampsBSDDB.py b/src/GrampsBSDDB.py index 681e02ef2..19a52a9a6 100644 --- a/src/GrampsBSDDB.py +++ b/src/GrampsBSDDB.py @@ -1042,25 +1042,21 @@ class GrampsBSDDB(GrampsDbBase): # Change every event handle to the EventRef if birth_handle: event_ref = EventRef() - event_ref.set_reference_handle(birth_handle) - event_ref.set_role((EventRef.PRIMARY,'')) + event_ref.ref = birth_handle + event_ref.role = (EventRef.PRIMARY,'') person.birth_ref = event_ref if death_handle: event_ref = EventRef() - event_ref.set_reference_handle(death_handle) - event_ref.set_role((EventRef.PRIMARY,'')) + event_ref.ref = death_handle + event_ref.role = (EventRef.PRIMARY,'') person.death_ref = event_ref - event_ref_list = [] for event_handle in event_list: event_ref = EventRef() - event_ref.set_reference_handle(event_handle) - event_ref.set_role((EventRef.PRIMARY,'')) - event_ref_list.append(event_ref) - - if event_ref_list: - person.event_ref_list = event_ref_list[:] + event_ref.ref = event_handle + event_ref.role = (EventRef.PRIMARY,'') + person.event_ref_list.append(event_ref) # In all Name instances, convert type from string to a tuple name_conversion = { @@ -1114,14 +1110,11 @@ class GrampsBSDDB(GrampsDbBase): family.marker = (PrimaryObject.MARKER_COMPLETE,"") # Change every event handle to the EventRef - event_ref_list = [] for event_handle in event_list: event_ref = EventRef() - event_ref.set_reference_handle(event_handle) - event_ref.set_role((EventRef.PRIMARY,'')) - event_ref_list.append(event_ref) - if event_ref_list: - family.event_ref_list = event_ref_list[:] + event_ref.ref = event_handle + event_ref.role = (EventRef.PRIMARY,'') + family.event_ref_list.append(event_ref) # In all Attributes, convert type from string to a tuple for attribute in family.attribute_list: @@ -1183,7 +1176,6 @@ class GrampsBSDDB(GrampsDbBase): "Will" : (Event.WILL,""), } - # Remove Witness from every event and convert name to type # cursor = self.get_event_cursor() # data = cursor.first() # while data: @@ -1194,8 +1186,8 @@ class GrampsBSDDB(GrampsDbBase): event.handle = handle (junk_handle, event.gramps_id, old_type, event.date, event.description, event.place, event.cause, event.private, - event.source_list, event.note, witness, event.media_list, - event.change) = info + event.source_list, event.note, witness_list, + event.media_list, event.change) = info if old_type: if event_conversion.has_key(old_type): @@ -1210,6 +1202,27 @@ class GrampsBSDDB(GrampsDbBase): for media_ref in event.media_list: convert_mediaref_9(media_ref) + # Upgrade witness -- no more Witness class + if type(witness_list) != list: + witness_list = [] + for witness in witness_list: + if witness.type == 0: # witness name recorded + # Add name and comment to the event note + note_text = event.get_note() + "\n" + \ + _("Witness name: %s") % witness.val + if witness.comment: + note_text += "\n" + _("Wittness comment: %s") \ + % witness.comment + event.set_note(note_text) + elif witness.type == 1: # witness ID recorded + # Add an EventRef from that person + # to this event using ROLE_WITNESS role + event_ref = EventRef() + event_ref.ref = event.handle + event_ref.role = (EventRef.WITNESS,'') + person = self.get_person_from_handle(witness.val) + person.event_ref_list.append(event_ref) + self.commit_person(person,trans) self.commit_event(event,trans) # data = cursor.next() # cursor.close() diff --git a/src/RelLib/_Event.py b/src/RelLib/_Event.py index f72eb2ba8..3f5d6ed61 100644 --- a/src/RelLib/_Event.py +++ b/src/RelLib/_Event.py @@ -121,12 +121,10 @@ class Event(PrimaryObject,SourceNote,MediaBase,DateBase,PlaceBase): self.description = source.description self.type = source.type self.cause = source.cause - self.ext_witness_list = source.ext_witness_list else: self.description = "" self.type = (Event.CUSTOM,"") self.cause = "" - self.ext_witness_list = [] def serialize(self): """ @@ -145,9 +143,9 @@ class Event(PrimaryObject,SourceNote,MediaBase,DateBase,PlaceBase): @rtype: tuple """ return (self.handle, self.gramps_id, self.type, self.date, - self.description, self.place, self.cause, self.private, - self.source_list, self.note, self.media_list, self.change, - self.marker, self.private) + self.description, self.place, self.cause, + self.source_list, self.note, self.media_list, + self.change, self.marker, self.private) def unserialize(self,data): """ @@ -159,9 +157,8 @@ class Event(PrimaryObject,SourceNote,MediaBase,DateBase,PlaceBase): @type data: tuple """ (self.handle, self.gramps_id, self.type, self.date, - self.description, self.place, self.cause, self.private, - self.source_list, self.note, self.media_list, self.change, - self.marker, self.private) = data + self.description, self.place, self.cause, self.source_list, self.note, + self.media_list, self.change, self.marker, self.private) = data def _has_handle_reference(self,classname,handle): if classname == 'Place': @@ -356,20 +353,3 @@ class Event(PrimaryObject,SourceNote,MediaBase,DateBase,PlaceBase): @rtype: str """ return self.description - - def add_ext_witness(self,witness): - assert type(witness) == tuple - self.ext_witness_list.append(witness) - - def remove_ext_witness(self,witness): - assert type(witness) == tuple - if witness in self.ext_witness_list: - self.ext_witness_list.remove(witness) - return True - return False - - def get_ext_witness_list(self): - return self.ext_witness_list - - def set_ext_witness_list(self,witness_list): - self.ext_witness_list = witness_list diff --git a/src/RelLib/_Witness.py b/src/RelLib/_Witness.py index 49c6b3519..3df81a3af 100644 --- a/src/RelLib/_Witness.py +++ b/src/RelLib/_Witness.py @@ -29,7 +29,7 @@ Witness class for GRAMPS # Witness class # #------------------------------------------------------------------------- -class Witness(BaseObject,PrivacyBase): +class Witness: # FIXME: this class is only present to enable db upgrade def __init__(self): pass diff --git a/src/RelLib/__init__.py b/src/RelLib/__init__.py index ec5f44868..b22fb5969 100644 --- a/src/RelLib/__init__.py +++ b/src/RelLib/__init__.py @@ -37,6 +37,7 @@ from _Note import Note from _RepoRef import RepoRef from _SourceRef import SourceRef from _Url import Url +from _Witness import Witness # Primary objects from _PrimaryObject import PrimaryObject