當前位置: 首頁>>代碼示例>>Python>>正文


Python Page.date_to_version_number方法代碼示例

本文整理匯總了Python中Sycamore.Page.Page.date_to_version_number方法的典型用法代碼示例。如果您正苦於以下問題:Python Page.date_to_version_number方法的具體用法?Python Page.date_to_version_number怎麽用?Python Page.date_to_version_number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sycamore.Page.Page的用法示例。


在下文中一共展示了Page.date_to_version_number方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: display_edits

# 需要導入模塊: from Sycamore.Page import Page [as 別名]
# 或者: from Sycamore.Page.Page import date_to_version_number [as 別名]

#.........這裏部分代碼省略.........
    if count_result: 
        totalEdits = count_result[0]

    request.cursor.execute("""SELECT count(DISTINCT name) from allPages
                              where userEdited=%(userid)s""",
                           {'userid':userid})
    count_result = request.cursor.fetchone()
    
    if count_result:
        editedPages = count_result[0]

    request.cursor.execute("""SELECT count(DISTINCT wiki_id) from allPages
                              where userEdited=%(userid)s""",
                           {'userid':userid})
    wiki_count_result = request.cursor.fetchone()
    if wiki_count_result:
        editedWikis = wiki_count_result[0]

    request.cursor.execute(
        """SELECT allPages.name, allPages.editTime, allPages.userIP,
                  allPages.editType, allPages.comment, wikis.name
           from allPages, wikis
           where allPages.userEdited=%(userid)s and
                 wikis.id=allPages.wiki_id
           order by editTime desc limit 100 offset %(offset)s""",
       {'userid':userid, 'offset':offset})
    results = request.cursor.fetchall()

    if results:
        has_edits = True
    
    count = 1
    original_wiki = request.config.wiki_name
    for edit in results:
        this_edit = 1 + totalEdits - count - offset

        pagename = edit[0]
        mtime = edit[1]
        userIp = '<a href="http://revip.info/ipinfo/%s" tooltip="%s">%s</a>' % (edit[2], edit[2], edit[2])
        editType = edit[3]
        comment = edit[4]
        wiki_name = edit[5]

        request.switch_wiki(wiki_name)
        page = Page(pagename, request, wiki_name=wiki_name)

        version = page.date_to_version_number(mtime)

        if request.user.may.read(page):
            may_read = True
            show_page = page.link_to(
                querystr='action=diff&amp;version2=%s&amp;version1=%s' %
                    (version, version-1),
                guess_case=True, absolute=True)
            formatted_mtime = request.user.getFormattedDateTime(mtime)
            comment = Comment(request, comment, editType).render()
        else:
            may_read = False
            show_page = """<em>hidden</em>"""
            userIp = '<em>hidden</em>'
            comment = '<em>hidden</em>'
            formatted_mtime = '<em>hidden</em>'
                     

        if config.wiki_farm:
            if may_read:
                farm_link = farm.link_to_wiki(wiki_name, request.formatter)
            else:
                farm_link = '<em>hidden</em>'
        
            edits.addRow((show_page,
                          farm_link,
                          formatted_mtime,
                          userIp,
                          comment))
        else:
            edits.addRow((show_page,
                          formatted_mtime,
                          userIp,
                          comment))
        count += 1

    request.switch_wiki(original_wiki)
    
    if has_edits:
        request.write('<p>This user has made <b>%d</b> edits to <b>%d</b> '
                      'pages' % (totalEdits, editedPages ))
        if config.wiki_farm:
            request.write(' on <b>%s</b> wikis' % editedWikis)
        request.write('.</p>')

        request.write('<div id="useredits">')
        edit_table = DataBrowserWidget(request)
        edit_table.setData(edits)
        edit_table.render(append=printNextPrev(request, on_pagename, this_edit,
                                               offset_given))
        request.write('</div>')
        request.write('<script type="text/javascript" src="/wiki/revipbox.js"></script>')
    else:
        request.write("<p>This user hasn't edited any pages.</p>")
開發者ID:rtucker,項目名稱:sycamore,代碼行數:104,代碼來源:userinfo.py


注:本文中的Sycamore.Page.Page.date_to_version_number方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。