diff options
author | NavaL <mnandri@thoughtworks.com> | 2016-01-18 17:38:21 +0100 |
---|---|---|
committer | NavaL <mnandri@thoughtworks.com> | 2016-01-18 17:38:21 +0100 |
commit | e5127c5710abbd77527d2dfa083a506a68ee23b3 (patch) | |
tree | 254ea720d34f74b8a6c7c1f9da740325c2c47441 /service/pixelated/resources/contacts_resource.py | |
parent | bb9a1c8827c02ac71c16b7d5d0b4c4c18b34f24c (diff) |
migrating contact resources to use the services factory
Issue #576
Diffstat (limited to 'service/pixelated/resources/contacts_resource.py')
-rw-r--r-- | service/pixelated/resources/contacts_resource.py | 12 |
1 files changed, 6 insertions, 6 deletions
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 <http://www.gnu.org/licenses/>. -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): |