aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/command/base.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-27 16:30:54 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-27 16:30:54 -0500
commitdff704764d77bffbf6cc94c5ba4bb03309da45f8 (patch)
tree3d0287d30718224903e3737545cbc970f3bdc898 /libbe/command/base.py
parent214c4317bb90684dcfdab4d2402daa66fbad2e77 (diff)
downloadbugseverywhere-dff704764d77bffbf6cc94c5ba4bb03309da45f8.tar.gz
Added storage.Storage.storage_version() and command.InvalidStorageVersion.
Now commands automatically check for storage version compatibility.
Diffstat (limited to 'libbe/command/base.py')
-rw-r--r--libbe/command/base.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/libbe/command/base.py b/libbe/command/base.py
index 6a49413..1409c74 100644
--- a/libbe/command/base.py
+++ b/libbe/command/base.py
@@ -6,6 +6,7 @@ import os.path
import sys
import libbe
+import libbe.storage
import libbe.ui.util.user
import libbe.util.encoding
import libbe.util.plugin
@@ -18,6 +19,15 @@ class UnknownCommand(UserError):
Exception.__init__(self, "Unknown command '%s'" % cmd)
self.cmd = cmd
+class InvalidStorageVersion(UserError):
+ def __init__(self, active_version, expected_version=None):
+ if expected_version == None:
+ expected_version = libbe.storage.STORAGE_VERSION
+ msg = 'Storage in "%s" not the expected "%s"' \
+ % (active_version, expected_version)
+ UserError.__init__(self, msg)
+ self.active_version = active_version
+ self.expected_version = expected_version
def get_command(command_name):
"""Retrieves the module for a user command
@@ -354,6 +364,9 @@ class Command (object):
if not hasattr(self, '_storage'):
self._storage = self._get_unconnected_storage()
self._storage.connect()
+ version = self._storage.storage_version()
+ if version != libbe.storage.STORAGE_VERSION:
+ raise InvalidStorageVersion(version)
return self._storage
def _get_bugdir(self):