summaryrefslogtreecommitdiff
path: root/service/pixelated/resources
diff options
context:
space:
mode:
authorDuda Dornelles <dudassdorneles@gmail.com>2015-01-21 19:48:50 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-21 19:48:50 -0200
commit70e6d825d6b3e6804d42f931f30a18445650f9b2 (patch)
tree3708c88d252c30b08600895211d2f1938facfaca /service/pixelated/resources
parent17617d102c0aa6a73cba51f1b6e425ec45384316 (diff)
#240 Adapted tests after change to twisted web
Diffstat (limited to 'service/pixelated/resources')
-rw-r--r--service/pixelated/resources/__init__.py3
-rw-r--r--service/pixelated/resources/mails_resource.py8
2 files changed, 6 insertions, 5 deletions
diff --git a/service/pixelated/resources/__init__.py b/service/pixelated/resources/__init__.py
index a2e4c9d4..9e9c154e 100644
--- a/service/pixelated/resources/__init__.py
+++ b/service/pixelated/resources/__init__.py
@@ -19,7 +19,8 @@ def respond_json(entity, request, status_code=200):
json_response = json.dumps(entity)
request.responseHeaders.addRawHeader(b"content-type", b"application/json")
request.code = status_code
- return json_response
+ request.write(json_response)
+ request.finish()
def respond_json_deferred(entity, request, status_code=200):
diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py
index 75c73349..d391382d 100644
--- a/service/pixelated/resources/mails_resource.py
+++ b/service/pixelated/resources/mails_resource.py
@@ -24,7 +24,7 @@ class MailsUnreadResource(Resource):
for ident in idents:
mail = self._mail_service.mark_as_unread(ident)
self._search_engine.index_mail(mail)
- return ""
+ return respond_json(None, request)
class MailsReadResource(Resource):
@@ -42,7 +42,7 @@ class MailsReadResource(Resource):
for ident in idents:
mail = self._mail_service.mark_as_read(ident)
self._search_engine.index_mail(mail)
- return ""
+ return respond_json(None, request)
class MailsDeleteResource(Resource):
@@ -89,11 +89,11 @@ class MailsResource(Resource):
response = {
"stats": {
"total": total,
- },
+ },
"mails": [mail.as_dict() for mail in mails]
}
- return json.dumps(response)
+ return respond_json(response, request)
def render_POST(self, request):
try: