def post(self): action = self.request.get('action') if action in all_actions: param = self.request.get('param') ex_param = self.request.get('ex_param') task = Task(action=action, param=param, status='waiting') if ex_param is not None: task.ex_param = ex_param if action in ['tweet', 'delete', 'follow', 'unfollow', 'retweet', 'direct_message', 'update_name', 'update_url', 'update_location', 'favorite', 'un-favorite']: task.status = 'ready' else: if self.request.get('redirect_url'): self.redirect(self.request.get('redirect_url')) else: self.response.out.write('{"status": "error"}') return if task.status == 'ready': last_time = memcache.get('last_time') if last_time <> None and (time.time()-last_time) > 60*10 or last_time == None: task.status = 'completed' response = do_task(task) task.put() if JABBER_UID is not None or len(JABBER_UID) > 0: xmpp.send_message(JABBER_UID, '%s: /%s %s %s'%(self.request.remote_addr, action, param, ex_param is not None and ex_param or '')) if self.request.get('redirect_url'): self.redirect(self.request.get('redirect_url')) else: self.response.out.write('{"status": "ok"}')
def post(self): action = self.request.get('action') if action in all_actions: param = self.request.get('param') ex_param = self.request.get('ex_param') task = Task(action=action, param=param, status='waiting') if ex_param is not None: task.ex_param = ex_param if action in [ 'tweet', 'delete', 'follow', 'unfollow', 'retweet', 'direct_message', 'update_name', 'update_url', 'update_location', 'favorite', 'un-favorite' ]: task.status = 'ready' else: if self.request.get('redirect_url'): self.redirect(self.request.get('redirect_url')) else: self.response.out.write('{"status": "error"}') return if task.status == 'ready': last_time = memcache.get('last_time') if last_time <> None and ( time.time() - last_time) > 60 * 10 or last_time == None: task.status = 'completed' response = do_task(task) task.put() if JABBER_UID is not None or len(JABBER_UID) > 0: xmpp.send_message( JABBER_UID, '%s: /%s %s %s' % (self.request.remote_addr, action, param, ex_param is not None and ex_param or '')) if self.request.get('redirect_url'): self.redirect(self.request.get('redirect_url')) else: self.response.out.write('{"status": "ok"}')
def get(self): task = Task(action='tweet', param='%d'%time.time(), status='ready') task.put()