summaryrefslogtreecommitdiff
path: root/backends/leap_backend.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-02-09 19:25:44 -0200
committerdrebs <drebs@leap.se>2013-02-09 20:21:48 -0200
commitf99762eef055742d841bae965ef3b1eec2ca4631 (patch)
treeb5af3f8a5ddb325110de07e9f4355c00f5b28144 /backends/leap_backend.py
parentbc6d05f8333ee775aa373817e2ece6323c62186f (diff)
Enforce doc.rev as bytes to match Twisted expectations.
Diffstat (limited to 'backends/leap_backend.py')
-rw-r--r--backends/leap_backend.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/backends/leap_backend.py b/backends/leap_backend.py
index 41027e50..d3ae6db6 100644
--- a/backends/leap_backend.py
+++ b/backends/leap_backend.py
@@ -22,6 +22,8 @@ class NoSoledadInstance(Exception):
class LeapDocument(Document):
"""
+ Encryptable and syncable document.
+
LEAP Documents are standard u1db documents with cabability of returning an
encrypted version of the document json string as well as setting document
content based on an encrypted version of json string.
@@ -37,7 +39,7 @@ class LeapDocument(Document):
def get_encrypted_json(self):
"""
- Returns document's json serialization encrypted with user's public key.
+ Return document's json serialization encrypted with user's public key.
"""
if not self._soledad:
raise NoSoledadInstance()
@@ -67,6 +69,22 @@ class LeapDocument(Document):
doc="Determine if document should be synced with server."
)
+ # Returning the revision as string solves the following exception in
+ # Twisted web:
+ # exceptions.TypeError: Can only pass-through bytes on Python 2
+ def _get_rev(self):
+ if self._rev is None:
+ return None
+ return str(self._rev)
+
+ def _set_rev(self, rev):
+ self._rev = rev
+
+ rev = property(
+ _get_rev,
+ _set_rev,
+ doc="Wrapper to ensure `doc.rev` is always returned as bytes.")
+
class LeapDatabase(HTTPDatabase):
"""Implement the HTTP remote database API to a Leap server."""