summaryrefslogtreecommitdiff
path: root/soledad/src
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-08-16 14:54:18 -0300
committerTomás Touceda <chiiph@leap.se>2013-08-16 14:54:18 -0300
commitd7aaa049fe8eb7c9ff039cb929901bddc1fd518e (patch)
treeea1bc1a4fafcaf05f81b14825f877d26c90946d2 /soledad/src
parenta9ddf49a05e3f6610dd5a96307c37fb4f4cf3d65 (diff)
parent342b441fe2236f23c8cb57b012d5e4adcfc65f0c (diff)
Merge remote-tracking branch 'kali/bug/check_for_none_in_priv_db' into develop
Diffstat (limited to 'soledad/src')
-rw-r--r--soledad/src/leap/soledad/__init__.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/soledad/src/leap/soledad/__init__.py b/soledad/src/leap/soledad/__init__.py
index 638ead8a..3fe9629f 100644
--- a/soledad/src/leap/soledad/__init__.py
+++ b/soledad/src/leap/soledad/__init__.py
@@ -855,7 +855,8 @@ class Soledad(object):
"number(fieldname, width)", "lower(fieldname)"
"""
- return self._db.create_index(index_name, *index_expressions)
+ if self._db:
+ return self._db.create_index(index_name, *index_expressions)
def delete_index(self, index_name):
"""
@@ -864,7 +865,8 @@ class Soledad(object):
@param index_name: The name of the index we are removing
@type index_name: str
"""
- return self._db.delete_index(index_name)
+ if self._db:
+ return self._db.delete_index(index_name)
def list_indexes(self):
"""
@@ -873,7 +875,8 @@ class Soledad(object):
@return: A list of [('index-name', ['field', 'field2'])] definitions.
@rtype: list
"""
- return self._db.list_indexes()
+ if self._db:
+ return self._db.list_indexes()
def get_from_index(self, index_name, *key_values):
"""
@@ -895,7 +898,8 @@ class Soledad(object):
@return: List of [Document]
@rtype: list
"""
- return self._db.get_from_index(index_name, *key_values)
+ if self._db:
+ return self._db.get_from_index(index_name, *key_values)
def get_range_from_index(self, index_name, start_value, end_value):
"""
@@ -924,8 +928,9 @@ class Soledad(object):
@return: List of [Document]
@rtype: list
"""
- return self._db.get_range_from_index(
- index_name, start_value, end_value)
+ if self._db:
+ return self._db.get_range_from_index(
+ index_name, start_value, end_value)
def get_index_keys(self, index_name):
"""
@@ -936,7 +941,8 @@ class Soledad(object):
@return: [] A list of tuples of indexed keys.
@rtype: list
"""
- return self._db.get_index_keys(index_name)
+ if self._db:
+ return self._db.get_index_keys(index_name)
def get_doc_conflicts(self, doc_id):
"""
@@ -948,7 +954,8 @@ class Soledad(object):
@return: a list of the document entries that are conflicted
@rtype: list
"""
- return self._db.get_doc_conflicts(doc_id)
+ if self._db:
+ return self._db.get_doc_conflicts(doc_id)
def resolve_doc(self, doc, conflicted_doc_revs):
"""
@@ -960,7 +967,8 @@ class Soledad(object):
supersedes.
@type conflicted_doc_revs: list
"""
- return self._db.resolve_doc(doc, conflicted_doc_revs)
+ if self._db:
+ return self._db.resolve_doc(doc, conflicted_doc_revs)
def sync(self):
"""
@@ -973,11 +981,12 @@ class Soledad(object):
performed.
@rtype: str
"""
- local_gen = self._db.sync(
- urlparse.urljoin(self.server_url, 'user-%s' % self._uuid),
- creds=self._creds, autocreate=True)
- signal(SOLEDAD_DONE_DATA_SYNC, self._uuid)
- return local_gen
+ if self._db:
+ local_gen = self._db.sync(
+ urlparse.urljoin(self.server_url, 'user-%s' % self._uuid),
+ creds=self._creds, autocreate=True)
+ signal(SOLEDAD_DONE_DATA_SYNC, self._uuid)
+ return local_gen
def need_sync(self, url):
"""