summaryrefslogtreecommitdiff
path: root/service/pixelated/resources/tags_resource.py
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2016-01-18 17:45:05 +0100
committerNavaL <mnandri@thoughtworks.com>2016-01-18 17:45:05 +0100
commita37ddad1b004c8b0f27b006284abd00483b17a95 (patch)
tree0b89ee1abee7957e0ecc83eb3941543a126e7345 /service/pixelated/resources/tags_resource.py
parente5127c5710abbd77527d2dfa083a506a68ee23b3 (diff)
migrating tag resources to use services factory
Issue #576
Diffstat (limited to 'service/pixelated/resources/tags_resource.py')
-rw-r--r--service/pixelated/resources/tags_resource.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/service/pixelated/resources/tags_resource.py b/service/pixelated/resources/tags_resource.py
index 8a8ab81f..6d4b7335 100644
--- a/service/pixelated/resources/tags_resource.py
+++ b/service/pixelated/resources/tags_resource.py
@@ -14,25 +14,25 @@
# 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.resource import Resource
from twisted.web.server import NOT_DONE_YET
-class TagsResource(Resource):
+class TagsResource(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', [''])[0]
skip_default_tags = request.args.get('skipDefaultTags', [False])[0]
- d = deferToThread(lambda: self._search_engine.tags(query=query, skip_default_tags=skip_default_tags))
+ d = deferToThread(lambda: _search_engine.tags(query=query, skip_default_tags=skip_default_tags))
d.addCallback(lambda tags: respond_json_deferred(tags, request))
return NOT_DONE_YET