summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-11-21 11:02:39 -0300
committerTomás Touceda <chiiph@leap.se>2013-11-21 11:02:39 -0300
commitd2f161e3efda601bccfc390392302f665f8a644b (patch)
tree3ace11d4b4276c86856f3e9b96080410f366ca9b
parentc17fe773748e6d07941016f608c6e7cfea0b043c (diff)
parent69fd3a11a3821468e737b8fb0e3e77abef0a4b8a (diff)
Merge remote-tracking branch 'drebs/bug/4095_add-unicode-conversion-to-put_doc' into develop
-rw-r--r--client/src/leap/soledad/client/__init__.py8
-rw-r--r--common/changes/bug_4095_add-unicode-conversion-to-put_doc1
-rw-r--r--scripts/README.rst17
-rw-r--r--scripts/client-side-db.py36
-rw-r--r--scripts/server-side-db.py38
-rw-r--r--server/changes/bug_4566_remove-creation-of-shared-db-from-soledad-server-code1
-rw-r--r--server/src/leap/soledad/server/__init__.py2
7 files changed, 101 insertions, 2 deletions
diff --git a/client/src/leap/soledad/client/__init__.py b/client/src/leap/soledad/client/__init__.py
index d50dde42..62f93b3d 100644
--- a/client/src/leap/soledad/client/__init__.py
+++ b/client/src/leap/soledad/client/__init__.py
@@ -747,12 +747,20 @@ class Soledad(object):
"""
Update a document in the local encrypted database.
+ ============================== WARNING ==============================
+ This method converts the document's contents to unicode in-place. This
+ meanse that after calling C{put_doc(doc)}, the contents of the
+ document, i.e. C{doc.content}, might be different from before the
+ call.
+ ============================== WARNING ==============================
+
:param doc: the document to update
:type doc: SoledadDocument
:return: the new revision identifier for the document
:rtype: str
"""
+ doc.content = self._convert_to_unicode(doc.content)
return self._db.put_doc(doc)
def delete_doc(self, doc):
diff --git a/common/changes/bug_4095_add-unicode-conversion-to-put_doc b/common/changes/bug_4095_add-unicode-conversion-to-put_doc
new file mode 100644
index 00000000..bed446ac
--- /dev/null
+++ b/common/changes/bug_4095_add-unicode-conversion-to-put_doc
@@ -0,0 +1 @@
+ o Add unicode conversion to put_doc(). Closes #4095.
diff --git a/scripts/README.rst b/scripts/README.rst
new file mode 100644
index 00000000..fdd1d642
--- /dev/null
+++ b/scripts/README.rst
@@ -0,0 +1,17 @@
+Soledad Scripts
+===============
+
+The scripts in this directory are meant to be used for development purposes.
+
+Currently, the scripts are:
+
+ * server-side-db.py: Gives access to server-side soledad user database,
+ based on the configuration in /etc/leap/soledad-server.conf. One should
+ use it as:
+
+ python -i server-side-db.py <uuid>
+
+ * client-side-db.py: Gives access to client-side soledad user database,
+ based on data stored in ~/.config/leap/soledad. One should use it as:
+
+ python -i client-side-db.py <uuid> <passphrase>
diff --git a/scripts/client-side-db.py b/scripts/client-side-db.py
new file mode 100644
index 00000000..0c3df7a4
--- /dev/null
+++ b/scripts/client-side-db.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+
+# This script gives client-side access to one Soledad user database by using
+# the data stored in ~/.config/leap/soledad/
+
+import sys
+import os
+
+from leap.common.config import get_path_prefix
+from leap.soledad.client import Soledad
+
+if len(sys.argv) != 3:
+ print 'Usage: %s <uuid> <passphrase>' % sys.argv[0]
+ exit(1)
+
+uuid = sys.argv[1]
+passphrase = unicode(sys.argv[2])
+
+secrets_path = os.path.join(get_path_prefix(), 'leap', 'soledad',
+ '%s.secret' % uuid)
+local_db_path = os.path.join(get_path_prefix(), 'leap', 'soledad',
+ '%s.db' % uuid)
+server_url = 'http://dummy-url'
+cert_file = 'cert'
+
+sol = Soledad(uuid, passphrase, secrets_path, local_db_path, server_url,
+ cert_file)
+db = sol._db
+
+# get replica info
+replica_uid = db._replica_uid
+gen, docs = db.get_all_docs()
+print "replica_uid: %s" % replica_uid
+print "generation: %d" % gen
+gen, trans_id = db._get_generation_info()
+print "transaction_id: %s" % trans_id
diff --git a/scripts/server-side-db.py b/scripts/server-side-db.py
new file mode 100644
index 00000000..01a9aaac
--- /dev/null
+++ b/scripts/server-side-db.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+# This script gives server-side access to one Soledad user database by using
+# the configuration stored in /etc/leap/soledad-server.conf.
+
+import sys
+from ConfigParser import ConfigParser
+
+from leap.soledad.common.couch import CouchDatabase
+
+if len(sys.argv) != 2:
+ print 'Usage: %s <uuid>' % sys.argv[0]
+ exit(1)
+
+uuid = sys.argv[1]
+
+# get couch url
+cp = ConfigParser()
+cp.read('/etc/leap/soledad-server.conf')
+url = cp.get('soledad-server', 'couch_url')
+
+# access user db
+dbname = 'user-%s' % uuid
+db = CouchDatabase(url, dbname)
+
+# get replica info
+replica_uid = db._replica_uid
+gen, docs = db.get_all_docs()
+print "dbname: %s" % dbname
+print "replica_uid: %s" % replica_uid
+print "generation: %d" % gen
+
+# get relevant docs
+schemes = map(lambda d: d.content['_enc_scheme'], docs)
+pubenc = filter(lambda d: d.content['_enc_scheme'] == 'pubkey', docs)
+
+print "total number of docs: %d" % len(docs)
+print "pubkey encrypted docs: %d" % len(pubenc)
diff --git a/server/changes/bug_4566_remove-creation-of-shared-db-from-soledad-server-code b/server/changes/bug_4566_remove-creation-of-shared-db-from-soledad-server-code
new file mode 100644
index 00000000..9e9a1b98
--- /dev/null
+++ b/server/changes/bug_4566_remove-creation-of-shared-db-from-soledad-server-code
@@ -0,0 +1 @@
+ o Remove creation of shared db from soledad server code. Closes #4566.
diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py
index c80b4c68..da806ad9 100644
--- a/server/src/leap/soledad/server/__init__.py
+++ b/server/src/leap/soledad/server/__init__.py
@@ -149,8 +149,6 @@ class SoledadApp(http_app.HTTPApp):
@return: HTTP application results.
@rtype: list
"""
- # ensure the shared database exists
- self.state.ensure_database(self.SHARED_DB_NAME)
return http_app.HTTPApp.__call__(self, environ, start_response)