def run_sql_proc(self, body, funcname):
try:
content = {'code': 0}
if funcname == 'notread':
if(body.has_key('userid')):
userid = body['userid']
res_list = DataCenter().get_not_read_id_from_xdata(userid)
list_dict = []
for i in range(len(res_list)):
tmp = {}
tmp['id'] = res_list[i]['id']
list_dict.append(tmp)
content['collections'] = list_dict
else:
content['code'] = -1
content['error'] = 'userid is needed.'
elif funcname == 'content':
if (body.has_key('userid') and body.has_key('id')):
userid = body['userid']
id = body['id']
res_list = DataCenter().get_content_from_xdata(userid, id)
content['id'] = res_list[0]['id']
content['title'] = res_list[0]['title']
content['author'] = res_list[0]['author']
content['source'] = res_list[0]['datasource']
content['subject'] = res_list[0]['aidata'].split(lingx_split_str)
content['original'] = res_list[0]['originaldata'].split(lingx_split_str)
#??accesstime
#DataCenter().update_xdata(id, 'accesstime', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
else:
content['code'] = -1
content['error'] = 'userid and id are needed.'
elif funcname == 'status':
if (body.has_key('article_list')):
for item in body['article_list']:
#??accesstime
DataCenter().update_xdata(item['id'], 'accesstime', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
else:
content['code'] = -1
content['error'] = 'article_list is empty.'
else:
pass
#print content
log.debug(content)
self.write(tornado.escape.json_encode(content))
self.finish()
except Exception, Argument:
log.error(Argument)
self.finish(Argument)
评论列表
文章目录