def build_whoosh_database(): analyzer = ChineseAnalyzer() schema = Schema(title=TEXT(stored=True, analyzer=analyzer), type=TEXT(stored=True), link=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer)) ix = create_in(whoosh_database, schema) writer = ix.writer() uu = MApp() tt = uu.get_all() for rec in tt: text2 = html2text.html2text(tornado.escape.xhtml_unescape( rec.cnt_html)) writer.add_document( title=rec.title, type='<span style="color:red;">[信息]</span>', link='/info/{0}'.format(rec.uid), content=text2, ) mpost = MPost() recs = mpost.query_all() for rec in recs: text2 = html2text.html2text(tornado.escape.xhtml_unescape( rec.cnt_html)) print(text2) writer.add_document(title=rec.title, type='<span style="color:blue;">[文档]</span>', link='/post/{0}.html'.format(rec.uid), content=text2) writer.commit()
def initialize(self): self.init() self.mpost = MPost() self.mcat = MInforCatalog() # self.cats = self.mcat.query_all() # self.mpost2catalog = MPost2Catalog() self.ysearch = yunsearch()
def render(self, current_id): self.mpost = MPost() prev_record = self.mpost.get_previous_record(current_id) if prev_record is None: outstr = '<a>已经是最后一篇了</a>' else: outstr = '''<a href="/post/{0}.html">上一篇</a>'''.format( prev_record.uid, prev_record.title) return outstr
def render(self, current_id): self.mpost = MPost() next_record = self.mpost.get_next_record(current_id) if next_record is None: outstr = '<a>已经是最新一篇了</a>' else: outstr = '''<a href="/post/{0}.html">下一篇</a>'''.format( next_record.uid) return outstr
def render(self, cat_id, list_num): self.mpost = MPost() recs = self.mpost.query_by_cat(cat_id, list_num) out_str = '' for rec in recs: tmp_str = '''<li><a href="/{0}">{1}</a></li>'''.format( rec.title, rec.title) out_str += tmp_str return out_str
def render(self, num, recent, with_date=True, with_catalog=True): self.mpost = MPost() recs = self.mpost.query_recent_most(num, recent) kwd = { 'with_date': with_date, 'with_catalog': with_catalog, } return self.render_string('doc/modules/post_list.html', recs=recs, kwd=kwd)
def render(self, cat_id, num, with_date=True, with_catalog=True): self.mpost = MPost() recs = self.mpost.query_cat_random(cat_id, num) kwd = { 'with_date': with_date, 'with_catalog': with_catalog, } return self.render_string('doc/modules/post_list.html', recs=recs, kwd=kwd)
def initialize(self): self.init() self.mpost = MPost() self.mcat = MCatalog() self.cats = self.mcat.query_all() self.mpost_hist = MPostHist() self.mpost2catalog = MPost2Catalog() self.mpost2reply = MPost2Reply() self.mpost2label = MPost2Label() self.mrel = MRelation()
def render(self, num=10, with_catalog=True, with_date=True): self.mpost = MPost() recs = self.mpost.query_recent(num) kwd = { 'with_date': with_date, 'with_catalog': with_catalog, } return self.render_string( 'doc/modules/post_list.html', recs=recs, unescape=tornado.escape.xhtml_unescape, kwd=kwd, )
def render( self, uid, num, ): self.mpost = MPost() self.relation = MRelApp2Post() kwd = { 'app_f': 'info', 'app_t': 'post', 'uid': uid, } rel_recs = self.relation.get_app_relations(uid, num) rand_recs = self.mpost.query_random(num - rel_recs.count() + 2) return self.render_string( 'infor/modules/relation_app2post.html', relations=rel_recs, rand_recs=rand_recs, kwd=kwd, )
def render(self, cat_id, num=10, with_catalog=True, with_date=True, width=160, height=120): self.mpost = MPost() self.mpost2cat = MPost2Catalog() recs = self.mpost.query_cat_recent(cat_id, num) kwd = { 'with_catalog': with_catalog, 'with_date': with_date, 'width': width, 'height': height, } return self.render_string( 'doc/modules/showout_list.html', recs=recs, unescape=tornado.escape.xhtml_unescape, kwd=kwd, )
def setup(self): print('setup 方法执行于本类中每条用例之前') self.uu = MPost() self.raw_count = self.uu.get_counts() self.post_title = 'ccc' self.uid = tools.get_uu4d()
def initialize(self): self.init() self.mpost = MPost() self.mcat = MCatalog() self.mpage = MPage() self.mlink = MLink()
def initialize(self): self.init() self.mpost = MPost() self.mcat = MCatalog() self.cats = self.mcat.query_all() self.mpost2catalog = MPost2Catalog()
def initialize(self): self.init() self.mapp = MApp() self.mpost = MPost() self.rel_post2app = MRelPost2App() self.rel_app2post = MRelApp2Post()
def initialize(self): self.init() self.mequa = MPost() self.mtag = MLabel() self.mapp2tag = MPost2Label()