From 45bf6c0f23a7abe90465299b0f6ddec896464d04 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 25 Jan 2007 05:26:22 +0000 Subject: [PATCH] 2007-01-24 Alex Roitman * src/RelLib/_Event.py (Event): Change inheritance order. * src/RelLib/_Family.py (Family): Change inheritance order. * src/RelLib/_MediaObject.py (MediaObject): Change inheritance order. * src/RelLib/_Place.py (Place): Change inheritance order. * src/RelLib/_Repository.py (Repository): Change inheritance order. * src/RelLib/_Person.py (Person): Change inheritance order. * src/RelLib/_Source.py (Source): Change inheritance order. (_has_handle_reference, _remove_handle_references, _replace_handle_reference): Add methods to report correct repository references. * src/DisplayTabs/_BackRefModel.py (__init__): Remove extra statement. svn: r7979 --- gramps2/ChangeLog | 13 ++++++ gramps2/src/DisplayTabs/_BackRefModel.py | 1 - gramps2/src/RelLib/_Event.py | 4 +- gramps2/src/RelLib/_Family.py | 4 +- gramps2/src/RelLib/_MediaObject.py | 2 +- gramps2/src/RelLib/_Person.py | 4 +- gramps2/src/RelLib/_Place.py | 2 +- gramps2/src/RelLib/_Repository.py | 2 +- gramps2/src/RelLib/_Source.py | 50 +++++++++++++++++++++++- 9 files changed, 71 insertions(+), 11 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 88fb63b13..1e8329619 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,16 @@ +2007-01-24 Alex Roitman + * src/RelLib/_Event.py (Event): Change inheritance order. + * src/RelLib/_Family.py (Family): Change inheritance order. + * src/RelLib/_MediaObject.py (MediaObject): Change inheritance order. + * src/RelLib/_Place.py (Place): Change inheritance order. + * src/RelLib/_Repository.py (Repository): Change inheritance order. + * src/RelLib/_Person.py (Person): Change inheritance order. + * src/RelLib/_Source.py (Source): Change inheritance order. + (_has_handle_reference, _remove_handle_references, + _replace_handle_reference): Add methods to report correct + repository references. + * src/DisplayTabs/_BackRefModel.py (__init__): Remove extra statement. + 2007-01-24 Brian Matherly * src/docgen/ODFDoc.py: Add "open with" option for book reports * src/docgen/OpenOfficeDoc.py: Add "open with" option for book reports diff --git a/gramps2/src/DisplayTabs/_BackRefModel.py b/gramps2/src/DisplayTabs/_BackRefModel.py index 0768bb874..9aed86bc4 100644 --- a/gramps2/src/DisplayTabs/_BackRefModel.py +++ b/gramps2/src/DisplayTabs/_BackRefModel.py @@ -49,7 +49,6 @@ class BackRefModel(gtk.ListStore): gtk.ListStore.__init__(self, str, str, str, str, str) self.db = db self.sref_list = sref_list - self.idle = 0 self.count = 0 self.idle = gobject.idle_add(self.load_model().next) diff --git a/gramps2/src/RelLib/_Event.py b/gramps2/src/RelLib/_Event.py index 0bac612df..042018c6a 100644 --- a/gramps2/src/RelLib/_Event.py +++ b/gramps2/src/RelLib/_Event.py @@ -45,8 +45,8 @@ from _EventType import EventType # Event class # #------------------------------------------------------------------------- -class Event(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase, - DateBase, PlaceBase): +class Event(SourceBase, NoteBase, MediaBase, AttributeBase, + DateBase, PlaceBase, PrimaryObject): """ Introduction ============ diff --git a/gramps2/src/RelLib/_Family.py b/gramps2/src/RelLib/_Family.py index ca82ba9f0..53d727f4d 100644 --- a/gramps2/src/RelLib/_Family.py +++ b/gramps2/src/RelLib/_Family.py @@ -53,8 +53,8 @@ from _FamilyRelType import FamilyRelType # Family class # #------------------------------------------------------------------------- -class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase, - LdsOrdBase): +class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase, + PrimaryObject): """ Introduction ============ diff --git a/gramps2/src/RelLib/_MediaObject.py b/gramps2/src/RelLib/_MediaObject.py index 8436adea8..8bb8bb275 100644 --- a/gramps2/src/RelLib/_MediaObject.py +++ b/gramps2/src/RelLib/_MediaObject.py @@ -49,7 +49,7 @@ from _AttributeBase import AttributeBase # MediaObject class # #------------------------------------------------------------------------- -class MediaObject(PrimaryObject, SourceBase, NoteBase, DateBase, AttributeBase): +class MediaObject(SourceBase,NoteBase,DateBase,AttributeBase,PrimaryObject): """ Containter for information about an image file, including location, description and privacy diff --git a/gramps2/src/RelLib/_Person.py b/gramps2/src/RelLib/_Person.py index c83cab2e7..3353e190c 100644 --- a/gramps2/src/RelLib/_Person.py +++ b/gramps2/src/RelLib/_Person.py @@ -50,8 +50,8 @@ from _EventRoleType import EventRoleType # Person class # #------------------------------------------------------------------------- -class Person(PrimaryObject, SourceBase, NoteBase, MediaBase, - AttributeBase, AddressBase, UrlBase, LdsOrdBase): +class Person(SourceBase, NoteBase, AttributeBase, MediaBase, + AddressBase, UrlBase, LdsOrdBase, PrimaryObject): """ Introduction ============ diff --git a/gramps2/src/RelLib/_Place.py b/gramps2/src/RelLib/_Place.py index a45229c25..d24a172ed 100644 --- a/gramps2/src/RelLib/_Place.py +++ b/gramps2/src/RelLib/_Place.py @@ -45,7 +45,7 @@ _EMPTY_LOC = Location().serialize() # Place class # #------------------------------------------------------------------------- -class Place(PrimaryObject, SourceBase, NoteBase, MediaBase, UrlBase): +class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject): """ Contains information related to a place, including multiple address information (since place names can change with time), longitude, latitude, diff --git a/gramps2/src/RelLib/_Repository.py b/gramps2/src/RelLib/_Repository.py index 5ae73efd5..2f0ded2bd 100644 --- a/gramps2/src/RelLib/_Repository.py +++ b/gramps2/src/RelLib/_Repository.py @@ -42,7 +42,7 @@ from _RepositoryType import RepositoryType # Repository class # #------------------------------------------------------------------------- -class Repository(PrimaryObject, NoteBase, AddressBase, UrlBase): +class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject): """A location where collections of Sources are found""" def __init__(self): diff --git a/gramps2/src/RelLib/_Source.py b/gramps2/src/RelLib/_Source.py index 142ccca6f..722f7d7c7 100644 --- a/gramps2/src/RelLib/_Source.py +++ b/gramps2/src/RelLib/_Source.py @@ -42,7 +42,7 @@ from _RepoRef import RepoRef # Source class # #------------------------------------------------------------------------- -class Source(PrimaryObject, MediaBase, NoteBase): +class Source(MediaBase, NoteBase, PrimaryObject): """A record of a source of information""" def __init__(self): @@ -85,6 +85,54 @@ class Source(PrimaryObject, MediaBase, NoteBase): MediaBase.unserialize(self, media_list) self.reporef_list = [RepoRef().unserialize(rr) for rr in reporef_list] + def _has_handle_reference(self, classname, handle): + """ + Returns True if the object has reference to a given handle + of given primary object type. + + @param classname: The name of the primary object class. + @type classname: str + @param handle: The handle to be checked. + @type handle: str + @return: Returns whether the object has reference to this handle of this object type. + @rtype: bool + """ + if classname == 'Repository': + return handle in [ref.ref for ref in self.reporef_list] + return False + + def _remove_handle_references(self, classname, handle_list): + """ + Removes all references in this object to object handles in the list. + + @param classname: The name of the primary object class. + @type classname: str + @param handle_list: The list of handles to be removed. + @type handle_list: str + """ + if classname == 'Repository': + new_list = [ ref for ref in self.reporef_list \ + if ref.ref not in handle_list ] + self.reporef_list = new_list + + def _replace_handle_reference(self, classname, old_handle, new_handle): + """ + Replaces all references to old handle with those to the new handle. + + @param classname: The name of the primary object class. + @type classname: str + @param old_handle: The handle to be replaced. + @type old_handle: str + @param new_handle: The handle to replace the old one with. + @type new_handle: str + """ + if classname == 'Repository': + handle_list = [ref.ref for ref in self.reporef_list] + while old_handle in handle_list: + ix = handle_list.index(old_handle) + self.reporef_list[ix].ref = new_handle + handle_list[ix] = '' + def get_text_data_list(self): """ Returns the list of all textual attributes of the object.