summaryrefslogtreecommitdiff
path: root/service/pixelated
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
parente5127c5710abbd77527d2dfa083a506a68ee23b3 (diff)
migrating tag resources to use services factory
Issue #576
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/resources/root_resource.py2
-rw-r--r--service/pixelated/resources/tags_resource.py12
2 files changed, 7 insertions, 7 deletions
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py
index 40895bff..c5985257 100644
--- a/service/pixelated/resources/root_resource.py
+++ b/service/pixelated/resources/root_resource.py
@@ -44,7 +44,7 @@ class RootResource(Resource):
self.putChild(AttachmentsResource.BASE_URL, AttachmentsResource(services_factory))
self.putChild('contacts', ContactsResource(services_factory))
self.putChild('features', FeaturesResource())
- self.putChild('tags', TagsResource(search_engine))
+ self.putChild('tags', TagsResource(services_factory))
self.putChild('mails', MailsResource(mail_service, draft_service))
self.putChild('mail', MailResource(mail_service))
self.putChild('feedback', FeedbackResource(feedback_service))
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