summaryrefslogtreecommitdiff
path: root/service/pixelated/resources/attachments_resource.py
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2016-01-18 17:27:19 +0100
committerNavaL <mnandri@thoughtworks.com>2016-01-18 17:27:19 +0100
commitbb9a1c8827c02ac71c16b7d5d0b4c4c18b34f24c (patch)
tree7027cf3f00276753c12514864c9527459063d77a /service/pixelated/resources/attachments_resource.py
parentc5d61bc8001b16e3dcedda9fd1229c27cca4bd3b (diff)
migrating AttachmentsResources to use the service factory
Issue #576
Diffstat (limited to 'service/pixelated/resources/attachments_resource.py')
-rw-r--r--service/pixelated/resources/attachments_resource.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/service/pixelated/resources/attachments_resource.py b/service/pixelated/resources/attachments_resource.py
index 09715282..249d268a 100644
--- a/service/pixelated/resources/attachments_resource.py
+++ b/service/pixelated/resources/attachments_resource.py
@@ -25,7 +25,7 @@ from twisted.web import server
from twisted.web.resource import Resource
from twisted.web.server import NOT_DONE_YET
-from pixelated.resources import respond_json_deferred
+from pixelated.resources import respond_json_deferred, BaseResource
logger = logging.getLogger(__name__)
@@ -72,21 +72,22 @@ class AttachmentResource(Resource):
return match.group(1)
-class AttachmentsResource(Resource):
+class AttachmentsResource(BaseResource):
BASE_URL = 'attachment'
- def __init__(self, mail_service):
- Resource.__init__(self)
- self.mail_service = mail_service
+ def __init__(self, services_factory):
+ BaseResource.__init__(self, services_factory)
def getChild(self, attachment_id, request):
- return AttachmentResource(self.mail_service, attachment_id)
+ _mail_service = self.mail_service(request)
+ return AttachmentResource(_mail_service, attachment_id)
def render_POST(self, request):
+ _mail_service = self.mail_service(request)
fields = cgi.FieldStorage(fp=request.content, headers=(request.getAllHeaders()),
environ={'REQUEST_METHOD': 'POST'})
_file = fields['attachment']
- deferred = self.mail_service.save_attachment(_file.value, _file.type)
+ deferred = _mail_service.save_attachment(_file.value, _file.type)
def send_location(attachment_id):
request.headers['Location'] = '/%s/%s' % (self.BASE_URL, attachment_id)