当前位置: 首页>>代码示例>>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;未经允许,请勿转载。