* src/ArgHandler.py (handle_args) Exit if opening a file failed
* src/Errors.py: New exception type "FileVersionError" * src/GrampsDbBase.py (version_supported): New method * src/GrampsBSDDB.py (version_supported): New method * src/gramps_main.py (read_file) catch FileVersionError; (post_load): only load if version_supported() * src/ReadGrdb.py (importData): only load if version_supported() svn: r4734
This commit is contained in:
parent
ebfbdce49b
commit
d77174143d
@ -1,3 +1,12 @@
|
||||
2005-05-30 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/ArgHandler.py (handle_args) Exit if opening a file failed
|
||||
* src/Errors.py: New exception type "FileVersionError"
|
||||
* src/GrampsDbBase.py (version_supported): New method
|
||||
* src/GrampsBSDDB.py (version_supported): New method
|
||||
* src/gramps_main.py (read_file) catch FileVersionError;
|
||||
(post_load): only load if version_supported()
|
||||
* src/ReadGrdb.py (importData): only load if version_supported()
|
||||
|
||||
2005-05-30 Matt Brubeck <mbrubeck@cs.hmc.edu>
|
||||
* src/DbPrompter.py: fix handling of spaces when creating a new
|
||||
file - use open instead of "touch"
|
||||
|
@ -304,6 +304,8 @@ class ArgHandler:
|
||||
# Add the file to the recent items
|
||||
RecentFiles.recent_files(filename,filetype)
|
||||
self.parent.build_recent_menu()
|
||||
else:
|
||||
os._exit(1)
|
||||
return
|
||||
|
||||
if self.open:
|
||||
|
@ -90,3 +90,15 @@ class GConfSchemaError(Exception):
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
class FileVersionError(Exception):
|
||||
"""
|
||||
Error used to report that a file could not be read because
|
||||
it is written in an unsupported version of the file format.
|
||||
"""
|
||||
def __init__(self,value):
|
||||
Exception.__init__(self)
|
||||
self.value = value
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
@ -111,6 +111,9 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
def get_media_cursor(self):
|
||||
return GrampsBSDDBCursor(self.media_map)
|
||||
|
||||
def version_supported(self):
|
||||
return self.metadata.get('version',0) <= _DBVERSION
|
||||
|
||||
def need_upgrade(self):
|
||||
return not self.readonly and self.metadata.get('version',0) < _DBVERSION
|
||||
|
||||
@ -407,6 +410,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
"Sponsored", "Foster", "Unknown", "Other", ]
|
||||
|
||||
version = self.metadata.get('version',0)
|
||||
|
||||
if version < 2:
|
||||
self.upgrade_2(child_rel_notrans)
|
||||
if version < 3:
|
||||
|
@ -191,6 +191,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.place2title = {}
|
||||
self.name_group = {}
|
||||
|
||||
def version_supported(self):
|
||||
""" Returns True when the file has a supported version"""
|
||||
return True
|
||||
|
||||
def need_upgrade(self):
|
||||
return False
|
||||
|
||||
|
@ -59,6 +59,15 @@ def importData(database, filename, callback=None,cl=0,use_trans=True):
|
||||
else:
|
||||
ErrorDialog(_("%s could not be opened") % filename)
|
||||
return
|
||||
if not other_database.version_supported():
|
||||
if cl:
|
||||
print "Error: %s could not be opened.\n%s Exiting." % (filename,\
|
||||
_("The database version is not supported by this version of GRAMPS.\n"\
|
||||
"Please upgrade to the corresponding version or use XML for porting data between different database versions."))
|
||||
else:
|
||||
ErrorDialog(_("%s could not be opened") % filename,
|
||||
_("The Database version is not supported by this version of GRAMPS."))
|
||||
return
|
||||
|
||||
# Check for duplicate handles. At the moment we simply exit here,
|
||||
# before modifying any data. In the future we will need to handle
|
||||
|
@ -1291,7 +1291,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
ErrorDialog(_('Cannot open database'),
|
||||
_('The database file specified could not be opened.'))
|
||||
return 0
|
||||
except ( IOError, OSError ), msg:
|
||||
except ( IOError, OSError, Errors.FileVersionError), msg:
|
||||
ErrorDialog(_('Cannot open database'),str(msg))
|
||||
return 0
|
||||
except (db.DBAccessError,db.DBError), msg:
|
||||
@ -1743,6 +1743,11 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
gtk.main_iteration()
|
||||
|
||||
def post_load(self,name,callback=None):
|
||||
if not self.db.version_supported():
|
||||
raise Errors.FileVersionError(
|
||||
"The database version is not supported by this version of GRAMPS.\n"
|
||||
"Please upgrade to the corresponding version or use XML for porting data between different database versions.")
|
||||
|
||||
self.db.set_save_path(name)
|
||||
res = self.db.get_researcher()
|
||||
owner = GrampsCfg.get_researcher()
|
||||
|
Loading…
x
Reference in New Issue
Block a user