summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-01-20 11:56:37 -0200
committerdrebs <drebs@leap.se>2013-01-20 11:56:37 -0200
commitc1e460cc15523a0138dde1ece9d584554d99c04b (patch)
tree4f677598f67ab1a4394bc7e4321984d955a4c32a
parent1af1eb0c413192d2919d4e344304bc617bfae2a5 (diff)
Fix SQLCipher implementation registering.
-rw-r--r--src/leap/soledad/backends/sqlcipher.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/leap/soledad/backends/sqlcipher.py b/src/leap/soledad/backends/sqlcipher.py
index 6711aa86..f7dc6c0b 100644
--- a/src/leap/soledad/backends/sqlcipher.py
+++ b/src/leap/soledad/backends/sqlcipher.py
@@ -61,6 +61,7 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
def set_pragma_key(cls, db_handle, key):
db_handle.cursor().execute("PRAGMA key = '%s'" % key)
+
def __init__(self, sqlite_file, password, document_factory=None):
"""Create a new sqlcipher file."""
self._check_if_db_is_encrypted(sqlite_file)
@@ -70,6 +71,7 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
self._ensure_schema()
self._factory = document_factory or Document
+
def _check_if_db_is_encrypted(self, sqlite_file):
if not os.path.exists(sqlite_file):
return
@@ -108,6 +110,7 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
return SQLCipherDatabase._sqlite_registry[v](
sqlite_file, password, document_factory=document_factory)
+
@classmethod
def open_database(cls, sqlite_file, password, create, backend_cls=None,
document_factory=None):
@@ -123,6 +126,7 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
return backend_cls(sqlite_file, password,
document_factory=document_factory)
+
@staticmethod
def register_implementation(klass):
"""Register that we implement an SQLCipherDatabase.
@@ -132,4 +136,5 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
SQLCipherDatabase._sqlite_registry[klass._index_storage_value] = klass
-SQLCipherDatabase.register_implementation(SQLCipherDatabase) \ No newline at end of file
+SQLiteDatabase.register_implementation(SQLCipherDatabase)
+