summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-11-03 00:01:46 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-11-03 00:01:46 +0100
commit7617b3f9fe7ab2d29f23babfa7bfbd1347253453 (patch)
tree207770d0ef5ed1b22b657a694dc1eabad7d5a917 /portato
parent2869169d44baa53eca78ec1e55342fe882b692c2 (diff)
downloadportato-7617b3f9fe7ab2d29f23babfa7bfbd1347253453.tar.gz
portato-7617b3f9fe7ab2d29f23babfa7bfbd1347253453.tar.bz2
portato-7617b3f9fe7ab2d29f23babfa7bfbd1347253453.zip
Add defaults only session loading
Diffstat (limited to '')
-rw-r--r--portato/gui/windows/main.py7
-rw-r--r--portato/session.py27
2 files changed, 21 insertions, 13 deletions
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index b76bb73..52786b3 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -704,6 +704,7 @@ class MainWindow (Window):
self.load_session(e)
except SessionException, e:
warning(str(e))
+ self.load_session(defaults_only = True) # last ressort
splash(_("Finishing startup"))
@@ -966,7 +967,7 @@ class MainWindow (Window):
else: # no selCatName -> so no category selected --> ignore
debug("No category selected --> should be no harm.")
- def load_session(self, sessionEx = None):
+ def load_session(self, sessionEx = None, defaults_only = False):
"""
Loads the session data.
"""
@@ -979,7 +980,7 @@ class MainWindow (Window):
oldVersion = SESSION_VERSION
allowedVersions = (1,2)
- if sessionEx and isinstance(sessionEx, SessionException):
+ if not defaults_only and sessionEx and isinstance(sessionEx, SessionException):
if sessionEx.got in allowedVersions:
info(_("Translating session from version %d to %d.") % (sessionEx.got, sessionEx.expected))
oldVersion = sessionEx.got
@@ -1171,7 +1172,7 @@ class MainWindow (Window):
self.session.add_handler(([(p.name.replace(" ","_"), "plugins")], load_plugin(p), save_plugin(p)))
# now we have the handlers -> load
- self.session.load()
+ self.session.load(defaults_only)
def jump_to (self, cp, version = None):
"""
diff --git a/portato/session.py b/portato/session.py
index 4b0edb0..4f904ed 100644
--- a/portato/session.py
+++ b/portato/session.py
@@ -63,21 +63,28 @@ class Session (object):
"""
self._handlers.append((options, load_fn, save_fn, default))
- def load (self):
+ def load (self, defaults_only = False):
"""
Loads and applies all values of the session.
"""
+
+ def ldefault (options, lfn, default):
+ if not default: return
+ debug("Loading %s with defaults %s.", options, default)
+ lfn(*default)
+
for options, lfn, sfn, default in self._handlers:
- try:
- loaded = [self._cfg.get(*x) for x in options]
- except KeyError: # does not exist -> ignore
- debug("No values for %s.", options)
- if default:
- debug("Loading %s with defaults %s.", options, default)
- lfn(*default)
+ if defaults_only:
+ ldefault(options, lfn, default)
else:
- debug("Loading %s with values %s.", options, loaded)
- lfn(*loaded)
+ try:
+ loaded = [self._cfg.get(*x) for x in options]
+ except KeyError: # does not exist -> ignore
+ debug("No values for %s.", options)
+ ldefault(options, lfn, default)
+ else:
+ debug("Loading %s with values %s.", options, loaded)
+ lfn(*loaded)
def save (self):
"""