Ejemplo n.º 1
0
 def test_query_random(self):
     self.add_mess()
     aa = MWiki.query_random(num=50)
     tf = False
     for i in aa:
         if i.uid == self.uid:
             tf = True
             break
     self.tearDown()
     assert tf
Ejemplo n.º 2
0
def do_for_wiki(writer, rand=True, doc_type=''):
    if rand:
        recs = MWiki.query_random(num=10, kind='1')
    else:
        recs = MWiki.query_recent(num=2, kind='1')

    for rec in recs:
        text2 = rec.title + ',' + html2text.html2text(
            tornado.escape.xhtml_unescape(rec.cnt_html))
        writer.update_document(title=rec.title,
                               catid='sid1',
                               type=doc_type,
                               link='/wiki/{0}'.format(rec.title),
                               content=text2)
Ejemplo n.º 3
0
def do_for_page(rand=True, doc_type=''):
    if rand:
        recs = MWiki.query_random(num=4, kind='2')
    else:
        recs = MWiki.query_recent(num=2, kind='2')

    for rec in recs:
        text2 = rec.title + ',' + html2text.html2text(
            tornado.escape.xhtml_unescape(rec.cnt_html))
        writer = TOR_IDX.writer()
        writer.update_document(title=rec.title,
                               catid='sid1',
                               type=doc_type,
                               link='/page/{0}'.format(rec.uid),
                               content=text2)
        writer.commit()
Ejemplo n.º 4
0
def do_for_wiki(writer, rand=True, doc_type=''):
    mpost = MWiki()
    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")
        writer.update_document(title=rec.title,
                               catid='0000',
                               type=doc_type,
                               link='/wiki/{0}'.format(rec.title),
                               content=text2)