summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorDuda Dornelles <dudassdornelles@gmail.com>2015-01-22 15:50:36 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-22 16:50:53 -0200
commit86ed99a7d78e4690d103f4334dc0eef03c47e402 (patch)
treedafd5d0aca3efb6f3c8afdc755c88423fba5991f /service/pixelated
parent81552abcfe67f61b68ad7cbf424738f7788f148c (diff)
#224 fixing tests and app for twisted migration
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/config/app_factory.py1
-rw-r--r--service/pixelated/resources/__init__.py4
-rw-r--r--service/pixelated/resources/attachments_resource.py8
-rw-r--r--service/pixelated/resources/contacts_resource.py3
-rw-r--r--service/pixelated/resources/mails_resource.py1
-rw-r--r--service/pixelated/resources/root_resource.py2
6 files changed, 12 insertions, 7 deletions
diff --git a/service/pixelated/config/app_factory.py b/service/pixelated/config/app_factory.py
index 9a80640b..86816b87 100644
--- a/service/pixelated/config/app_factory.py
+++ b/service/pixelated/config/app_factory.py
@@ -116,6 +116,7 @@ def create_app(app, args):
listen_with_ssl(app, args)
else:
listen_without_ssl(app, args)
+ reactor.suggestThreadPoolSize(20)
reactor.callWhenRunning(lambda: init_app(app, args.home))
reactor.run()
diff --git a/service/pixelated/resources/__init__.py b/service/pixelated/resources/__init__.py
index 9e9c154e..92a4462f 100644
--- a/service/pixelated/resources/__init__.py
+++ b/service/pixelated/resources/__init__.py
@@ -19,8 +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
- request.write(json_response)
- request.finish()
+ return json_response
+ # request.finish()
def respond_json_deferred(entity, request, status_code=200):
diff --git a/service/pixelated/resources/attachments_resource.py b/service/pixelated/resources/attachments_resource.py
index 0ab214b9..e0ba1bd1 100644
--- a/service/pixelated/resources/attachments_resource.py
+++ b/service/pixelated/resources/attachments_resource.py
@@ -19,10 +19,14 @@ import io
import re
from twisted.protocols.basic import FileSender
from twisted.python.log import err
+from twisted.web import server
from twisted.web.resource import Resource
class AttachmentResource(Resource):
+
+ isLeaf = True
+
def __init__(self, attachment_id, querier):
Resource.__init__(self)
self.attachment_id = attachment_id
@@ -44,7 +48,7 @@ class AttachmentResource(Resource):
d.addErrback(err).addCallback(cb_finished)
- return d
+ return server.NOT_DONE_YET
def _extract_mimetype(self, content_type):
match = re.compile('([A-Za-z-]+\/[A-Za-z-]+)').search(content_type)
@@ -53,8 +57,6 @@ class AttachmentResource(Resource):
class AttachmentsResource(Resource):
- isLeaf = True
-
def __init__(self, querier):
Resource.__init__(self)
self.querier = querier
diff --git a/service/pixelated/resources/contacts_resource.py b/service/pixelated/resources/contacts_resource.py
index 94468a63..5ec39761 100644
--- a/service/pixelated/resources/contacts_resource.py
+++ b/service/pixelated/resources/contacts_resource.py
@@ -16,6 +16,7 @@
from pixelated.resources import respond_json_deferred
from twisted.internet.threads import deferToThread
+from twisted.web import server
from twisted.web.resource import Resource
@@ -32,4 +33,4 @@ class ContactsResource(Resource):
d = deferToThread(lambda: self._search_engine.contacts(query))
d.addCallback(lambda tags: respond_json_deferred(tags, request))
- return d
+ return server.NOT_DONE_YET
diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py
index ccd03ad6..a6eb0fe0 100644
--- a/service/pixelated/resources/mails_resource.py
+++ b/service/pixelated/resources/mails_resource.py
@@ -122,4 +122,5 @@ class MailsResource(Resource):
else:
pixelated_mail = self._draft_service.create_draft(_mail)
self._search_engine.index_mail(pixelated_mail)
+
return respond_json({'ident': pixelated_mail.ident}, request)
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py
index f230415d..7768472c 100644
--- a/service/pixelated/resources/root_resource.py
+++ b/service/pixelated/resources/root_resource.py
@@ -23,7 +23,7 @@ class RootResource(Resource):
def initialize(self, querier, search_engine, mail_service, draft_service):
self.putChild('assets', File(self._static_folder))
- self.putChild('attachments', AttachmentsResource(querier))
+ self.putChild('attachment', AttachmentsResource(querier))
self.putChild('contacts', ContactsResource(search_engine))
self.putChild('features', FeaturesResource())
self.putChild('sync_info', SyncInfoResource())