summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2016-01-19 10:00:27 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2016-01-19 10:00:27 +0100
commit2771d5e8930041b8bcef3ff78e2456bef45554e1 (patch)
tree41c0bc48fd7732cad3fbe34349af7a5ad1ba95d5 /service/pixelated
parentc96ee7ab8e6a365e8f2a848f35a3f0af8bb9389b (diff)
Make RootResource read account email from mail service
- Issue #576
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/application.py9
-rw-r--r--service/pixelated/resources/root_resource.py31
2 files changed, 22 insertions, 18 deletions
diff --git a/service/pixelated/application.py b/service/pixelated/application.py
index 2d7eb36d..aa0db132 100644
--- a/service/pixelated/application.py
+++ b/service/pixelated/application.py
@@ -63,7 +63,7 @@ class ServicesFactory(object):
@defer.inlineCallbacks
-def start_user_agent(root_resource, leap_home, leap_session):
+def start_user_agent(root_resource, services_factory, leap_home, leap_session):
log.info('Bootstrap done, loading services for user %s' % leap_session.user_auth.username)
services = Services(leap_home, leap_session)
@@ -72,10 +72,9 @@ def start_user_agent(root_resource, leap_home, leap_session):
if leap_session.fresh_account:
yield add_welcome_mail(leap_session.mail_store)
- services_factory = ServicesFactory()
services_factory.add_session(leap_session.user_auth.uuid, services)
- root_resource.initialize(services_factory, services.mail_service)
+ root_resource.initialize()
# soledad needs lots of threads
reactor.threadpool.adjustPoolsize(5, 15)
@@ -101,7 +100,8 @@ def initialize():
log.info('Starting the Pixelated user agent')
args = arguments.parse_user_agent_args()
logger.init(debug=args.debug)
- resource = RootResource()
+ services_factory = ServicesFactory()
+ resource = RootResource(services_factory)
start_site(args, resource)
@@ -114,6 +114,7 @@ def initialize():
deferred.addCallback(
lambda leap_session: start_user_agent(
resource,
+ services_factory,
args.leap_home,
leap_session))
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py
index b17e33fd..0894444b 100644
--- a/service/pixelated/resources/root_resource.py
+++ b/service/pixelated/resources/root_resource.py
@@ -1,6 +1,8 @@
import os
import requests
from string import Template
+
+from pixelated.resources import BaseResource
from pixelated.resources.attachments_resource import AttachmentsResource
from pixelated.resources.contacts_resource import ContactsResource
from pixelated.resources.features_resource import FeaturesResource
@@ -18,13 +20,14 @@ MODE_STARTUP = 1
MODE_RUNNING = 2
-class RootResource(Resource):
+class RootResource(BaseResource):
- def __init__(self):
- Resource.__init__(self)
+ def __init__(self, services_factory):
+ BaseResource.__init__(self, services_factory)
self._startup_assets_folder = self._get_startup_folder()
self._static_folder = self._get_static_folder()
self._html_template = open(os.path.join(self._static_folder, 'index.html')).read()
+ self._services_factory = services_factory
self._startup_mode()
def _startup_mode(self):
@@ -36,18 +39,17 @@ class RootResource(Resource):
return self
return Resource.getChild(self, path, request)
- def initialize(self, services_factory, mail_service):
- self.account_email = mail_service.account_email
+ def initialize(self):
self.putChild('assets', File(self._static_folder))
- self.putChild('keys', KeysResource(services_factory))
- self.putChild(AttachmentsResource.BASE_URL, AttachmentsResource(services_factory))
- self.putChild('contacts', ContactsResource(services_factory))
+ self.putChild('keys', KeysResource(self._services_factory))
+ self.putChild(AttachmentsResource.BASE_URL, AttachmentsResource(self._services_factory))
+ self.putChild('contacts', ContactsResource(self._services_factory))
self.putChild('features', FeaturesResource())
- self.putChild('tags', TagsResource(services_factory))
- self.putChild('mails', MailsResource(services_factory))
- self.putChild('mail', MailResource(services_factory))
- self.putChild('feedback', FeedbackResource(services_factory))
- self.putChild('user-settings', UserSettingsResource(services_factory))
+ self.putChild('tags', TagsResource(self._services_factory))
+ self.putChild('mails', MailsResource(self._services_factory))
+ self.putChild('mail', MailResource(self._services_factory))
+ self.putChild('feedback', FeedbackResource(self._services_factory))
+ self.putChild('user-settings', UserSettingsResource(self._services_factory))
self._mode = MODE_RUNNING
@@ -72,5 +74,6 @@ class RootResource(Resource):
if self._is_starting():
return open(os.path.join(self._startup_assets_folder, 'Interstitial.html')).read()
else:
- response = Template(self._html_template).safe_substitute(account_email=self.account_email)
+ account_email = self.mail_service(request).account_email
+ response = Template(self._html_template).safe_substitute(account_email=account_email)
return str(response)