diff --git a/ChangeLog b/ChangeLog index 5e77e2c35..ed3b6eae1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ 2007-10-08 Alex Roitman + * src/gen/db/dbdir.py (__close_metadata): Store tuple; + (_load_metadata): Load from tuple; + * src/gen/db/base.py (GrampsDbBase.set_researcher): Move details + to the Researcher class. * src/gen/lib/researcher.py (serialize, unserialize): Add methods; + (set_from): Add method; (set, get): Remove methods. + (__init__): Copy from source if provided. 2007-10-08 Don Allingham * src/gen/lib/attrbase.py: renamed from attributeBase.py diff --git a/src/gen/db/base.py b/src/gen/db/base.py index 44a7ee5be..8a1d48ae9 100644 --- a/src/gen/db/base.py +++ b/src/gen/db/base.py @@ -1753,10 +1753,7 @@ class GrampsDbBase(GrampsDBCallback): def set_researcher(self, owner): """sets the information about the owner of the database""" - self.owner.set(owner.get_name(), owner.get_address(), - owner.get_city(), owner.get_state(), - owner.get_country(), owner.get_postal_code(), - owner.get_phone(), owner.get_email()) + self.owner.set_from(owner) def get_researcher(self): """returns the Researcher instance, providing information about diff --git a/src/gen/db/dbdir.py b/src/gen/db/dbdir.py index 4ad345e84..889b2f5df 100644 --- a/src/gen/db/dbdir.py +++ b/src/gen/db/dbdir.py @@ -608,8 +608,9 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback): # database owner try: - self.set_researcher(self.metadata.get('researcher', - default=self.owner)) + owner_data = self.metadata.get('researcher') + if owner_data: + self.owner.unserialize(owner_data) except ImportError: #handle problems with pre-alpha 3.0 pass @@ -1139,7 +1140,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback): self.metadata.put('name_formats',self.name_formats,txn=the_txn) # database owner - self.metadata.put('researcher', self.owner, txn=the_txn) + owner_data = self.owner.serialize() + self.metadata.put('researcher', owner_data, txn=the_txn) # bookmarks self.metadata.put('bookmarks',self.bookmarks.get(),txn=the_txn) diff --git a/src/gen/lib/researcher.py b/src/gen/lib/researcher.py index 42f1698f6..09b144057 100644 --- a/src/gen/lib/researcher.py +++ b/src/gen/lib/researcher.py @@ -41,13 +41,19 @@ from locationbase import LocationBase class Researcher(LocationBase): """Contains the information about the owner of the database""" - def __init__(self): - """Initializes the Researcher object""" + def __init__(self, source=None): + """Initializes the Researcher object, + copying from the source if provided""" - LocationBase.__init__(self ) - self.name = "" - self.addr = "" - self.email = "" + LocationBase.__init__(self, source) + if source: + self.name = source.name + self.addr = source.addr + self.email = source.email + else: + self.name = "" + self.addr = "" + self.email = "" def serialize(self): """ @@ -88,3 +94,17 @@ class Researcher(LocationBase): def get_email(self): """returns the database owner's email""" return self.email + + def set_from(self,other_researcher): + """set all attributes from another instance""" + self.street = other_researcher.street + self.city = other_researcher.city + self.county = other_researcher.county + self.state = other_researcher.state + self.country = other_researcher.country + self.postal = other_researcher.postal + self.phone = other_researcher.phone + + self.name = other_researcher.name + self.addr = other_researcher.addr + self.email = other_researcher.email