Esempio n. 1
0
    def get(self, user_id, mode=None):
        user_id = _smart_user_id(self, user_id)

        ctx = self.context()

        if not user_id:
            user_id = ctx.get('current_user_id')

        if mode not in ["list", "url", "lists", "urls"]:
            mode = "list"

        api_msg = MBMessage(None, 'fetch_user_network',
                    {'user_id': user_id, 'mode': mode}, {}, ctx)

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 2
0
    def get(self, user_id, mode=None):
        user_id = _smart_user_id(self, user_id)

        ctx = self.context()

        if not user_id:
            user_id = ctx.get('current_user_id')

        if mode not in ["list", "url", "lists", "urls"]:
            mode = "list"

        api_msg = MBMessage(None, 'fetch_user_network', {
            'user_id': user_id,
            'mode': mode
        }, {}, ctx)

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 3
0
    def get(self):
        api_msg = MBMessage(None, 'fetch_hashtags', {}, {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 4
0
    def get(self, user_id=None):
        api_msg = MBMessage(None, 'fetch_user',
                            {'user_id': user_id}, {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 5
0
    def get(self, hashtag):
        api_msg = MBMessage(None, 'fetch_hashtag',
                    {'hashtag': hashtag}, {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 6
0
    def get(self):
        ctx = self.context()

        api_msg = MBMessage(None, 'fetch_popular', {}, {}, ctx)

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 7
0
    def get(self, edition=None):
        ctx = self.context()

        api_msg = MBMessage(None, 'fetch_followmore', {}, {}, ctx)

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 8
0
    def get(self, categories=None):
        api_msg = MBMessage(None, 'fetch_list_by_categories',
                            {'categories': categories}, {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.guess_ctype()
        self.write(resp.payload)
        self.finish()
Esempio n. 9
0
    def get(self, categories=None):
        api_msg = MBMessage(None, 'fetch_list_by_categories',
                            {'categories': categories}, {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.guess_ctype()
        self.write(resp.payload)
        self.finish()
Esempio n. 10
0
    def get(self, action):
        args_as_list = self.request.arguments

        payload = {k: v[0] for k, v in args_as_list.iteritems()}

        api_msg = MBMessage(None, action, {}, payload, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            raw_resp = yield go.dispatch()
            resp = go.make_response(raw_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 11
0
    def post(self):
        query = self.get_argument('q') or self.get_argument('query')

        api_msg = MBMessage(None, 'beta_search_url', {'query': query}, {},
                            self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 12
0
    def get(self, user_id=None):
        api_msg = MBMessage(None, 'fetch_user_profile', {'user_id': user_id},
                            {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.guess_ctype()

        self.write(resp.payload)
        self.finish()
Esempio n. 13
0
    def get(self, key=""):
        api_msg = MBMessage(None, 'fetch_landing',
                  {}, {'key': key}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.guess_ctype()

        self.write(resp.payload)
        self.finish()
Esempio n. 14
0
    def get(self, action):
        args_as_list = self.request.arguments

        payload = {k: v[0] for k, v in args_as_list.iteritems()}

        api_msg = MBMessage(None, action, {}, payload, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            raw_resp = yield go.dispatch()
            resp = go.make_response(raw_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 15
0
    def get(self, key=""):
        api_msg = MBMessage(None, 'fetch_landing', {}, {'key': key},
                            self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.guess_ctype()

        self.write(resp.payload)
        self.finish()
Esempio n. 16
0
    def get(self, category=None):
        ctx = self.context()

        api_msg = MBMessage(None, 'fetch_topusers',
                       {'category': category or choice(CATEGORIES)}, {}, ctx)

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 17
0
    def post(self):
        query = self.get_argument('q') or self.get_argument('query')

        api_msg = MBMessage(None, 'beta_search_url',
                            {'query': query}, {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 18
0
    def get(self, edition=None):
        ctx = self.context()

        api_msg = MBMessage(None, 'fetch_toplists',
                       {}, {'edition': edition or ""}, ctx)

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 19
0
    def get(self, category=None):
        ctx = self.context()

        api_msg = MBMessage(None, 'fetch_topusers',
                            {'category': category or choice(CATEGORIES)}, {},
                            ctx)

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 20
0
    def get(self, user_id=None):
        if not user_id:
            user_id = self.context().get("current_user_id")

        api_msg = MBMessage(None, 'fetch_notifications', {'user_id': user_id},
                            {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 21
0
    def post(self):
        api_msg = self.decode_api_msg(self.request.body)

        go = GoHandler.can_handle(self, api_msg)
        if go:
            resp = yield go.dispatch()

            resp_msg = go.make_response(resp)
        else:
            resp = yield self.dispatch(api_msg)

            resp_msg = MBMessage(resp.msg_id, resp.action,
                                 api_msg.target, resp.payload, resp.context, merge_target=False)

            self.mb_cookies(resp)

        self.set_header('Content-Type', 'application/json')
        self.write(resp_msg.to_json())
        self.finish()
Esempio n. 22
0
    def post(self):
        api_msg = self.decode_api_msg(self.request.body)

        go = GoHandler.can_handle(self, api_msg)
        if go:
            resp = yield go.dispatch()

            resp_msg = go.make_response(resp)
        else:
            resp = yield self.dispatch(api_msg)

            resp_msg = MBMessage(resp.msg_id,
                                 resp.action,
                                 api_msg.target,
                                 resp.payload,
                                 resp.context,
                                 merge_target=False)

            self.mb_cookies(resp)

        self.set_header('Content-Type', 'application/json')
        self.write(resp_msg.to_json())
        self.finish()
Esempio n. 23
0
    def get(self):
        self.guess_ctype()

        if self.is_anonymous():
            self.write(json.dumps({'notifications': []}))
            self.finish()

            return

        api_msg = MBMessage(None, 'fetch_contrib_notifications', {}, {},
                            self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()
Esempio n. 24
0
    def get(self):
        self.guess_ctype()

        if self.is_anonymous():
            self.write(json.dumps({'notifications': []}))
            self.finish()

            return

        api_msg = MBMessage(None, 'fetch_contrib_notifications',
                            {}, {}, self.context())

        go = GoHandler.can_handle(self, api_msg)

        if go:
            go_resp  = yield go.dispatch()

            resp = go.make_response(go_resp)
        else:
            resp = yield self.dispatch(api_msg)

        self.write(resp.payload)
        self.finish()