Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-10-01 05:33:11 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-10-01 05:33:18 (GMT)
commit43de9257019b12c50db370f28bcbda1816a8de01 (patch)
tree40b1446f0957fd042318bb96d1faf8ebaa4cc264
parent93200cb50f261fe0a46bec0f83d395063dacff1d (diff)
Direct blob values will be passed via json, so, use base64
-rw-r--r--active_document/storage.py3
-rwxr-xr-xtests/units/document.py3
2 files changed, 4 insertions, 2 deletions
diff --git a/active_document/storage.py b/active_document/storage.py
index 87757ae..d9806f6 100644
--- a/active_document/storage.py
+++ b/active_document/storage.py
@@ -19,6 +19,7 @@ import time
import json
import shutil
import hashlib
+from base64 import b64decode
from os.path import exists, join, isdir, basename, relpath, lexists, isabs
from active_document import env
@@ -183,7 +184,7 @@ class Record(object):
blob_path = join(self._root, prop + PropertyMeta.BLOB_SUFFIX)
if content is not None:
with util.new_file(blob_path) as f:
- f.write(content)
+ f.write(b64decode(content))
elif path and exists(path):
util.cptree(path, blob_path)
diff --git a/tests/units/document.py b/tests/units/document.py
index 0c6c0db..a8a8ca2 100755
--- a/tests/units/document.py
+++ b/tests/units/document.py
@@ -9,6 +9,7 @@ import json
import time
import urllib2
import hashlib
+from base64 import b64encode
from cStringIO import StringIO
from os.path import join, exists
@@ -722,7 +723,7 @@ class DocumentTest(tests.Test):
self.assertEqual('blob-1', file('document/1/1/blob.blob').read())
directory.merge('1', {
- 'blob': {'mtime': 5, 'content': 'blob-2'},
+ 'blob': {'mtime': 5, 'content': b64encode('blob-2')},
})
self.assertEqual(5, doc.meta('blob')['mtime'])