def do_for_app(writer, rand=True): mpost = MApp() if rand: recs = mpost.query_random(50) else: recs = mpost.query_recent(50) doc_type = '<span style="color:blue;" class="glyphicon glyphicon-map-marker">[{0}]</span>'.format( '地图') print(recs.count()) for rec in recs: # # sleep(0.1) text2 = rec.title + ',' + html2text.html2text( tornado.escape.xhtml_unescape(rec.cnt_html)) # writer.update_document(path=u"/a",content="Replacement for the first document") writer.update_document(title=rec.title, type=doc_type, link='/map/{0}'.format(rec.uid), content=text2)
def do_for_app(writer, rand=True, kind='', doc_type=''): mpost = MApp() if rand: recs = mpost.query_random(50, kind=kind) else: recs = mpost.query_recent(50, kind=kind) print(recs.count()) for rec in recs: # # sleep(0.1) text2 = rec.title + ',' + html2text.html2text( tornado.escape.xhtml_unescape(rec.cnt_html)) writer.update_document(catid='00000', title=rec.title, type=doc_type[rec.kind], link='/{0}/{1}'.format(router_post[rec.kind], rec.uid), content=text2)
def do_for_app2(writer, rand=True): mpost = MApp() if rand: recs = mpost.query_random(50) else: recs = mpost.query_recent(50) print(recs.count()) for rec in recs: # # sleep(0.1) text2 = rec.title + ',' + html2text.html2text( tornado.escape.xhtml_unescape(rec.cnt_html)) # writer.update_document(path=u"/a",content="Replacement for the first document") info = minfo2tag.get_entry_catalog(rec.uid) if info: print(info.uid) print(info.tag.uid) print(info.tag.kind) pass else: continue catid = info.tag.uid[:2] + '00' cat_name = '' if 'def_cat_uid' in rec.extinfo and rec.extinfo['def_cat_uid']: uu = mappcat.get_by_uid(rec.extinfo['def_cat_uid'][:2] + '00') if uu: cat_name = uu.name writer.update_document( title=rec.title, catid=catid, type='<span style="color:red;">[{0}]</span>'.format(cat_name), link='/{0}/{1}'.format(router_post[rec.kind], rec.uid), content=text2)
class UserListHandler(BaseHandler): def initialize(self): self.init() self.mequa = MInfor() self.musage = MUsage() def get(self, url_str=''): if len(url_str) > 0: url_arr = url_str.split('/') if url_str == 'recent': self.to_find(url_str) if url_str == 'app': self.list_app() elif url_str == 'user_recent': self.user_recent() elif url_str == 'user_most': self.user_most() def list_app(self): kwd = { 'pager': '', 'title': '最近使用的运算应用', } self.render( 'user/info_list/list_app.html', kwd=kwd, userinfo=self.userinfo, ) @tornado.web.authenticated def user_most(self): kwd = { 'pager': '', 'title': '我使用最多的云算应用', } self.render( 'user/info_list/user_most.html'.format(input), kwd=kwd, user_name=self.get_current_user(), userinfo=self.userinfo, ) @tornado.web.authenticated def user_recent(self): kwd = {'pager': '', 'title': '我最近使用的云算应用'} self.render( 'user/info_list/user_recent.html'.format(input), kwd=kwd, user_name=self.get_current_user(), userinfo=self.userinfo, ) def post(self, input=''): if len(input) > 0: ip_arr = input.split(r'/') if input == 'find': self.find() def to_find(self, input): kwd = { 'pager': '', } self.render('user/info_list/most.html'.format(input), topmenu='', userinfo=self.userinfo, kwd=kwd) def list_recent(self): recs = self.mequa.query_recent(20) kwd = { 'pager': '', 'title': '最近使用的云算应用', } self.render( 'user/info_list/list.html'.format(input), kwd=kwd, rand_eqs=self.get_random(), recs=recs, userinfo=self.userinfo, ) def find(self): keyword = self.get_argument('keyword').strip() kwd = { 'pager': '', 'title': '查找结果', } self.render('user/info_list/find_list.html'.format(input), userinfo=self.userinfo, kwd=kwd, recs=self.mequa.get_by_keyword(keyword)) def get_random(self): return self.mequa.query_random()