Ejemplo n.º 1
0
    def post(self, screen_name, slug):
        token = md.get_default_access_token()
        if not token:
            self.write(json.dumps({
                'success':False,
                'info':'No access token avaliable.',
            }))
            return

        td = Twitdao(token)
        buser=None
        if 'add' == slug:
            buser = td.blocks_create(screen_name = screen_name)
        else:
            buser = td.blocks_destroy(screen_name = screen_name)
        taskqueue.add(queue_name='cache', url='/q/update_user_cache', params={'tk':token.key(), 'user_id':token.user_id}, method="GET" )
        taskqueue.add(queue_name='cache', url='/q/update_user_cache', params={'tk':token.key(), 'screen_name':screen_name}, method="GET" )

        if 'error' in buser:
            self.write(json.dumps({
                'success':False,
                'info':buser['error'],
            }))
        else:
            self.write(json.dumps({
                'success':True,
                'info':'OK',
                'user':buser,
            }))
Ejemplo n.º 2
0
    def post(self, screen_name):
        token = md.get_default_access_token()
        if not token:
            self.redirect("/settings")
            return

        td = Twitdao(token)
        block_user = td.blocks_create(screen_name=screen_name)
        taskqueue.add(
            queue_name="cache",
            url="/q/update_user_cache",
            params={"tk": token.key(), "user_id": token.user_id},
            method="GET",
        )
        taskqueue.add(
            queue_name="cache",
            url="/q/update_user_cache",
            params={"tk": token.key(), "screen_name": screen_name},
            method="GET",
        )
        self.redirect("/m/u-%s" % screen_name)