summaryrefslogtreecommitdiff
path: root/service/pixelated/resources
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-08-07 09:30:51 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:33 +0200
commit6b588bb4cb93f8e265d044ea784cb18b7021b26c (patch)
tree01eacc11e8c6bf0a21312cc9b9295f68872130a0 /service/pixelated/resources
parent08497951fa9aed8d28be8b2dea1aef2135f56769 (diff)
Changed test_delete_mail.py integration test to new mail store.
- intermediate state, some tests are broken
Diffstat (limited to 'service/pixelated/resources')
-rw-r--r--service/pixelated/resources/__init__.py11
-rw-r--r--service/pixelated/resources/mails_resource.py6
2 files changed, 14 insertions, 3 deletions
diff --git a/service/pixelated/resources/__init__.py b/service/pixelated/resources/__init__.py
index b244900a..c65e19f3 100644
--- a/service/pixelated/resources/__init__.py
+++ b/service/pixelated/resources/__init__.py
@@ -17,15 +17,22 @@
import json
+class SetEncoder(json.JSONEncoder):
+ def default(self, obj):
+ if isinstance(obj, set):
+ return list(obj)
+ return super(SetEncoder, self).default(obj)
+
+
def respond_json(entity, request, status_code=200):
- json_response = json.dumps(entity)
+ json_response = json.dumps(entity, cls=SetEncoder)
request.responseHeaders.addRawHeader(b"content-type", b"application/json")
request.code = status_code
return json_response
def respond_json_deferred(entity, request, status_code=200):
- json_response = json.dumps(entity)
+ json_response = json.dumps(entity, cls=SetEncoder)
request.responseHeaders.addRawHeader(b"content-type", b"application/json")
request.code = status_code
request.write(json_response)
diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py
index d4e8372e..9658bd82 100644
--- a/service/pixelated/resources/mails_resource.py
+++ b/service/pixelated/resources/mails_resource.py
@@ -123,6 +123,11 @@ class MailsResource(Resource):
})
d.addCallback(lambda res: respond_json_deferred(res, request))
+ def error_handler(error):
+ print error
+
+ d.addErrback(error_handler)
+
return NOT_DONE_YET
def render_POST(self, request):
@@ -146,7 +151,6 @@ class MailsResource(Resource):
return server.NOT_DONE_YET
def render_PUT(self, request):
- print '\nrender_PUT\n'
content_dict = json.loads(request.content.read())
_mail = InputMail.from_dict(content_dict)
draft_id = content_dict.get('ident')