* 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.
	(set_from): Add method;
	(__init__): Copy from source if provided.


svn: r9104
This commit is contained in:
Alex Roitman 2007-10-08 18:30:10 +00:00
parent 5d94a0d690
commit 7b6d8b5146
4 changed files with 38 additions and 13 deletions

View File

@ -1,6 +1,12 @@
2007-10-08 Alex Roitman <shura@gramps-project.org> 2007-10-08 Alex Roitman <shura@gramps-project.org>
* 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; * src/gen/lib/researcher.py (serialize, unserialize): Add methods;
(set_from): Add method;
(set, get): Remove methods. (set, get): Remove methods.
(__init__): Copy from source if provided.
2007-10-08 Don Allingham <don@gramps-project.org> 2007-10-08 Don Allingham <don@gramps-project.org>
* src/gen/lib/attrbase.py: renamed from attributeBase.py * src/gen/lib/attrbase.py: renamed from attributeBase.py

View File

@ -1753,10 +1753,7 @@ class GrampsDbBase(GrampsDBCallback):
def set_researcher(self, owner): def set_researcher(self, owner):
"""sets the information about the owner of the database""" """sets the information about the owner of the database"""
self.owner.set(owner.get_name(), owner.get_address(), self.owner.set_from(owner)
owner.get_city(), owner.get_state(),
owner.get_country(), owner.get_postal_code(),
owner.get_phone(), owner.get_email())
def get_researcher(self): def get_researcher(self):
"""returns the Researcher instance, providing information about """returns the Researcher instance, providing information about

View File

@ -608,8 +608,9 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
# database owner # database owner
try: try:
self.set_researcher(self.metadata.get('researcher', owner_data = self.metadata.get('researcher')
default=self.owner)) if owner_data:
self.owner.unserialize(owner_data)
except ImportError: #handle problems with pre-alpha 3.0 except ImportError: #handle problems with pre-alpha 3.0
pass pass
@ -1139,7 +1140,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
self.metadata.put('name_formats',self.name_formats,txn=the_txn) self.metadata.put('name_formats',self.name_formats,txn=the_txn)
# database owner # 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 # bookmarks
self.metadata.put('bookmarks',self.bookmarks.get(),txn=the_txn) self.metadata.put('bookmarks',self.bookmarks.get(),txn=the_txn)

View File

@ -41,13 +41,19 @@ from locationbase import LocationBase
class Researcher(LocationBase): class Researcher(LocationBase):
"""Contains the information about the owner of the database""" """Contains the information about the owner of the database"""
def __init__(self): def __init__(self, source=None):
"""Initializes the Researcher object""" """Initializes the Researcher object,
copying from the source if provided"""
LocationBase.__init__(self ) LocationBase.__init__(self, source)
self.name = "" if source:
self.addr = "" self.name = source.name
self.email = "" self.addr = source.addr
self.email = source.email
else:
self.name = ""
self.addr = ""
self.email = ""
def serialize(self): def serialize(self):
""" """
@ -88,3 +94,17 @@ class Researcher(LocationBase):
def get_email(self): def get_email(self):
"""returns the database owner's email""" """returns the database owner's email"""
return self.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