Prevent crash from exporting because of no default person.

Because of changes in [1], if self.get_default_handle() doesn't return a handle, we would have a crash.

5c958bd7fb
This commit is contained in:
Doug Blank 2015-12-13 12:01:25 -05:00
parent 7710544936
commit 03a72b8319

View File

@ -476,14 +476,18 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
@catch_db_error
def get_default_person(self):
"""Return the default Person of the database."""
person = self.get_person_from_handle(self.get_default_handle())
if person:
return person
elif (self.metadata) and (not self.readonly):
# Start transaction
with BSDDBTxn(self.env, self.metadata) as txn:
txn.put(b'default', None)
return None
person_handle = self.get_default_handle()
if person_handle:
person = self.get_person_from_handle(person_handle)
if person:
return person
elif (self.metadata) and (not self.readonly):
# Start transaction
with BSDDBTxn(self.env, self.metadata) as txn:
txn.put(b'default', None)
return None
else:
return None
def set_mediapath(self, path):
"""Set the default media path for database, path should be utf-8."""