From e5127c5710abbd77527d2dfa083a506a68ee23b3 Mon Sep 17 00:00:00 2001 From: NavaL Date: Mon, 18 Jan 2016 17:38:21 +0100 Subject: migrating contact resources to use the services factory Issue #576 --- service/pixelated/resources/contacts_resource.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'service/pixelated/resources/contacts_resource.py') diff --git a/service/pixelated/resources/contacts_resource.py b/service/pixelated/resources/contacts_resource.py index 43155774..dc17d1ac 100644 --- a/service/pixelated/resources/contacts_resource.py +++ b/service/pixelated/resources/contacts_resource.py @@ -14,23 +14,23 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . -from pixelated.resources import respond_json_deferred +from pixelated.resources import respond_json_deferred, BaseResource from twisted.internet.threads import deferToThread from twisted.web import server from twisted.web.resource import Resource -class ContactsResource(Resource): +class ContactsResource(BaseResource): isLeaf = True - def __init__(self, search_engine): - Resource.__init__(self) - self._search_engine = search_engine + def __init__(self, services_factory): + BaseResource.__init__(self, services_factory) def render_GET(self, request): + _search_engine = self.search_engine(request) query = request.args.get('q', [''])[-1] - d = deferToThread(lambda: self._search_engine.contacts(query)) + d = deferToThread(lambda: _search_engine.contacts(query)) d.addCallback(lambda tags: respond_json_deferred(tags, request)) def handle_error(error): -- cgit v1.2.3