* src/GrampsDb/_GrampsDbBase.py: fix typo
* src/GrampsDb/_GrampsDBDir.py: check for writability, otherwise open as readonly * src/DbManager.py: use single, user configurable database path * data/gramps.schemas.in: set default path to ~/.gramps/grampsdb 2007-06-16 Don Allingham <don@gramps-project.org> svn: r8566
This commit is contained in:
parent
10430f3321
commit
7da9ba3e6a
@ -1,6 +1,12 @@
|
||||
2007-06-16 Alex Roitman <shura@gramps-project.org>
|
||||
* src/GrampsDbUtils/_ReadXML.py (start_url): Correctly parse url type.
|
||||
|
||||
2007-06-16 Don Allingham <don@gramps-project.org>
|
||||
* src/GrampsDb/_GrampsDbBase.py: fix typo
|
||||
* src/GrampsDb/_GrampsDBDir.py: check for writability, otherwise open as readonly
|
||||
* src/DbManager.py: use single, user configurable database path
|
||||
* data/gramps.schemas.in: set default path to ~/.gramps/grampsdb
|
||||
|
||||
2007-06-16 Don Allingham <don@gramps-project.org>
|
||||
* src/GrampsCfg.py: additional database path
|
||||
* src/Config/_GrampsConfigKeys.py: additional database path
|
||||
|
@ -603,7 +603,7 @@
|
||||
<applyto>/apps/gramps/behavior/database-path</applyto>
|
||||
<owner>gramps</owner>
|
||||
<type>string</type>
|
||||
<default></default>
|
||||
<default>~/.gramps/grampsdb</default>
|
||||
<locale name="C">
|
||||
<short>Additional path where the databases may reside</short>
|
||||
<long>Additional path where the databases may reside</long>
|
||||
|
@ -225,35 +225,30 @@ class DbManager:
|
||||
self.model = gtk.ListStore(str, str, str, str, int, bool, str)
|
||||
|
||||
# make the default directory if it does not exist
|
||||
|
||||
dbdir = os.path.expanduser(Config.get(Config.DATABASE_PATH))
|
||||
|
||||
try:
|
||||
if not os.path.isdir(DEFAULT_DIR):
|
||||
os.mkdir(DEFAULT_DIR)
|
||||
if not os.path.isdir(dbdir):
|
||||
os.mkdir(dbdir)
|
||||
except (IOError, OSError), msg:
|
||||
LOG.error(_("Could not make database directory: ") + str(msg))
|
||||
|
||||
additional = Config.get(Config.DATABASE_PATH).strip()
|
||||
|
||||
pathlist = [ DEFAULT_DIR ]
|
||||
|
||||
if os.path.isdir(additional):
|
||||
pathlist.append(additional)
|
||||
|
||||
self.current_names = []
|
||||
|
||||
for path in pathlist:
|
||||
for dpath in os.listdir(path):
|
||||
dirpath = os.path.join(path, dpath)
|
||||
path_name = os.path.join(dirpath, NAME_FILE)
|
||||
if os.path.isfile(path_name):
|
||||
name = file(path_name).readline().strip()
|
||||
for dpath in os.listdir(dbdir):
|
||||
dirpath = os.path.join(dbdir, dpath)
|
||||
path_name = os.path.join(dirpath, NAME_FILE)
|
||||
if os.path.isfile(path_name):
|
||||
name = file(path_name).readline().strip()
|
||||
|
||||
(tval, last) = time_val(dirpath)
|
||||
(enable, stock_id) = icon_values(dirpath, self.active,
|
||||
self.dbstate.db.is_open())
|
||||
(tval, last) = time_val(dirpath)
|
||||
(enable, stock_id) = icon_values(dirpath, self.active,
|
||||
self.dbstate.db.is_open())
|
||||
|
||||
self.current_names.append(
|
||||
(name, os.path.join(DEFAULT_DIR, dpath), path_name,
|
||||
last, tval, enable, stock_id))
|
||||
self.current_names.append(
|
||||
(name, os.path.join(dbdir, dpath), path_name,
|
||||
last, tval, enable, stock_id))
|
||||
|
||||
self.current_names.sort()
|
||||
for items in self.current_names:
|
||||
|
@ -433,11 +433,22 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
||||
|
||||
def load(self, name, callback, mode="w"):
|
||||
try:
|
||||
if self.__check_readonly(name):
|
||||
mode = "r"
|
||||
return self.__load(name, callback, mode)
|
||||
except DBERRS, msg:
|
||||
print name
|
||||
self.__log_error()
|
||||
raise Errors.DbError(msg)
|
||||
|
||||
def __check_readonly(self, name):
|
||||
for base in [ FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, EVENTS_TBL,
|
||||
PERSON_TBL, REPO_TBL, NOTE_TBL, REF_MAP, META ]:
|
||||
path = os.path.join(name, base + ".db")
|
||||
if not os.access(path, os.W_OK):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __load(self, name, callback, mode="w"):
|
||||
|
||||
if self.db_is_open:
|
||||
@ -500,7 +511,7 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
||||
self.repository_map = self.__open_table(self.full_name, REPO_TBL)
|
||||
self.note_map = self.__open_table(self.full_name, NOTE_TBL)
|
||||
self.reference_map = self.__open_table(self.full_name, REF_MAP,
|
||||
dbtype=db.DB_BTREE)
|
||||
dbtype=db.DB_BTREE)
|
||||
if callback:
|
||||
callback(37)
|
||||
|
||||
|
@ -748,7 +748,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
return index
|
||||
|
||||
def __get_from_handle(self, handle, class_type, data_map):
|
||||
data = data_map.get(str(handle),txn=self.txn)
|
||||
data = data_map.get(str(handle))
|
||||
if data:
|
||||
newobj = class_type()
|
||||
newobj.unserialize(data)
|
||||
|
Loading…
Reference in New Issue
Block a user