本文整理汇总了Python中MoinMoin.Page.Page.current_rev方法的典型用法代码示例。如果您正苦于以下问题:Python Page.current_rev方法的具体用法?Python Page.current_rev怎么用?Python Page.current_rev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.Page.Page
的用法示例。
在下文中一共展示了Page.current_rev方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xmlrpc_getPageInfoVersion
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import current_rev [as 别名]
def xmlrpc_getPageInfoVersion(self, pagename, rev):
"""
Return page information for specific revision
@param pagename: the name of the page (utf-8)
@param rev: revision to get info about (int)
@rtype: dict
@return: page information
* name (string): the canonical page name, UTF-8.
* lastModified (date): Last modification date, UTC.
* author (string): author name, UTF-8.
* version (int): current version
"""
pn = self._instr(pagename)
# User may read this page?
if not self.request.user.may.read(pn):
return self.notAllowedFault()
if rev is not None:
page = Page(self.request, pn, rev=rev)
else:
page = Page(self.request, pn)
rev = page.current_rev()
# Non existing page?
if not page.exists():
return self.noSuchPageFault()
# Get page info
edit_info = page.edit_info()
if not edit_info:
return self.noLogEntryFault()
mtime = wikiutil.version2timestamp(long(edit_info['timestamp'])) # must be long for py 2.2.x
gmtuple = tuple(time.gmtime(mtime))
version = rev # our new rev numbers: 1,2,3,4,....
#######################################################################
# BACKWARDS COMPATIBILITY CODE - remove when 1.2.x is regarded stone age
# as we run a feed for BadContent on MoinMaster, we want to stay
# compatible here for a while with 1.2.x moins asking us for BadContent
# 1.3 uses the lastModified field for checking for updates, so it
# should be no problem putting the old UNIX timestamp style of version
# number in the version field
if self.request.cfg.sitename == 'MoinMaster' and pagename == 'BadContent':
version = int(mtime)
#######################################################################
return {
'name': self._outstr(page.page_name),
'lastModified': xmlrpclib.DateTime(gmtuple),
'author': self._outstr(edit_info['editor']),
'version': version,
}
示例2: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import current_rev [as 别名]
def execute(pagename, request):
""" Handle "action=diff"
checking for either a "rev=formerrevision" parameter
or rev1 and rev2 parameters
"""
if not request.user.may.read(pagename):
Page(request, pagename).send_page()
return
try:
date = request.values['date']
try:
date = long(date) # must be long for py 2.2.x
except StandardError:
date = 0
except KeyError:
date = 0
try:
rev1 = int(request.values.get('rev1', -1))
except StandardError:
rev1 = 0
try:
rev2 = int(request.values.get('rev2', 0))
except StandardError:
rev2 = 0
if rev1 == -1 and rev2 == 0:
rev1 = request.rev
if rev1 is None:
rev1 = -1
# spacing flag?
ignorews = int(request.values.get('ignorews', 0))
_ = request.getText
# get a list of old revisions, and back out if none are available
currentpage = Page(request, pagename)
currentrev = currentpage.current_rev()
if currentrev < 2:
request.theme.add_msg(_("No older revisions available!"), "error")
currentpage.send_page()
return
if date: # this is how we get called from RecentChanges
rev1 = 0
log = editlog.EditLog(request, rootpagename=pagename)
for line in log.reverse():
if date >= line.ed_time_usecs and int(line.rev) != 99999999:
rev1 = int(line.rev)
break
else:
rev1 = 1
rev2 = 0
if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
rev1, rev2 = rev2, rev1
if rev1 == -1:
oldrev = currentrev - 1
oldpage = Page(request, pagename, rev=oldrev)
elif rev1 == 0:
oldrev = currentrev
oldpage = currentpage
else:
oldrev = rev1
oldpage = Page(request, pagename, rev=oldrev)
if rev2 == 0:
newrev = currentrev
newpage = currentpage
else:
newrev = rev2
newpage = Page(request, pagename, rev=newrev)
oldlog = oldpage.editlog_entry()
newlog = newpage.editlog_entry()
if not oldlog or not newlog:
# We use "No log entries found." msg because we already have i18n
# for that. Better would "At least one log entry was not found.".
request.theme.add_msg(_("No log entries found."), "error")
currentpage.send_page()
return
edit_count = abs(newrev - oldrev)
# Start output
# This action generates content in the user language
request.setContentLanguage(request.lang)
request.theme.send_title(_('Diff for "%s"') % (pagename, ), pagename=pagename, allow_doubleclick=1)
f = request.formatter
request.write(f.div(1, id="content"))
oldrev = oldpage.get_real_rev()
newrev = newpage.get_real_rev()
#.........这里部分代码省略.........
示例3: commentform
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import current_rev [as 别名]
def commentform(tmpauthor, tmptext, tmppasswd, tmpicon, comrev, tmpautopass, tmpmarkup):
# A form for posting a new comment
request = Globs.macro.request
datapagename = Globs.datapagename
_ = request.getText
cellstyle = u'border-width: 0px; vertical-align: middle; font-size: 0.9em;'
pg = Page( request, datapagename )
if pg.exists():
comrev = pg.current_rev()
else:
comrev = 0
if not Params.nosmiley:
if not Params.smileylist:
iconlist = getsmileymarkupradio(tmpicon)
else:
iconlist = getsmileymarkuplist(tmpicon)
else:
iconlist = ''
initName = ''
initPass = ''
initText = ''
if not (request.user.valid or tmpauthor):
tmpauthor = getAuthorFromCookie()
if not tmpauthor:
import socket
host = request.remote_addr
try:
hostname = socket.gethostbyaddr(host)[0]
except socket.error:
hostname = host
tmpauthor = hostname.split('.')[0]
initName = tmpauthor
if not tmppasswd:
tmppasswd = nicepass()
initPass = tmppasswd
elif tmpautopass and tmpautopass == tmppasswd:
tmppasswd = nicepass()
initPass = tmppasswd
if not tmptext:
tmptext = u'Add your comment'
initText = tmptext
elif tmptext and tmptext == u'Add your comment':
initText = tmptext
previewbutton = ''
markupcheckbox = ''
if Params.markup:
if not (tmpmarkup == '0'):
markupchecked = "checked"
else:
markupchecked = ''
previewbutton = '<br><input type="submit" name="button_preview" value="%s" style="color: #ff7777; font-size: 9pt; width: 6em; ">' % _('Preview')
markupcheckbox = '<input type="checkbox" name="commarkup%d" value="1" %s> Markup' % (Globs.formid, markupchecked)
if request.user.valid:
html1 = [
u'<input type="hidden" value="%s" name="comauthor">' % request.user.name,
u'<input type="hidden" value="*" name="compasswd">',
]
authorJavascriptCode = ''
onSubmitCode = ''
else:
html1 = [
u'<input type="text" style="font-size: 9pt;" size="6" maxlength="20" name="comauthor" value="%(author)s" onfocus="if (this.value==\'%(msg)s\') {this.value=\'\';};" onblur="if (this.value==\'\') {this.value=\'%(msg)s\';};">' % { 'msg': wikiutil.escape(initName), 'cellstyle': cellstyle, 'author': wikiutil.escape(tmpauthor) },
u'<input type="password" style="font-size: 9pt;" size="4" maxlength="10" name="compasswd" value="%(passwd)s" onfocus="if (this.value==\'%(msg)s\') {this.value=\'\';};" onblur="if (this.value==\'\') {this.value=\'%(msg)s\';};">' % { 'msg': wikiutil.escape(initPass), 'passwd': wikiutil.escape(tmppasswd) },
u'<input type="hidden" value="%s" name="autopasswd">' % wikiutil.escape(initPass),
]
authorJavascriptCode = """
<script language="javascript">
<!--
function setCookie(name, value) {
var today = new Date();
var expire = new Date(today.getTime() + 60*60*24*365*1000);
document.cookie = name + "=" + encodeURIComponent(value) + "; expires=" + expire.toGMTString() + "; path=%s";
}
//-->
</script>""" % request.getScriptname()
onSubmitCode = 'onSubmit="setCookie(\'PG2AUTHOR\', this.comauthor.value);"'
html1 = u'\n'.join(html1)
scripthtml = u'onfocus="if (this.value==\'%(msg)s\') {this.value=\'\';};" onblur="if (this.value==\'\') {this.value=\'%(msg)s\';};"' % {'msg': wikiutil.escape(initText) }
#.........这里部分代码省略.........
示例4: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import current_rev [as 别名]
def execute(pagename, request):
""" Handle "action=diff"
checking for either a "rev=formerrevision" parameter
or rev1 and rev2 parameters
"""
if not request.user.may.read(pagename):
Page(request, pagename).send_page()
return
try:
date = request.form['date'][0]
try:
date = long(date) # must be long for py 2.2.x
except StandardError:
date = 0
except KeyError:
date = 0
try:
rev1 = int(request.form.get('rev1', [-1])[0])
except StandardError:
rev1 = 0
try:
rev2 = int(request.form.get('rev2', [0])[0])
except StandardError:
rev2 = 0
if rev1 == -1 and rev2 == 0:
rev1 = request.rev
if rev1 is None:
rev1 = -1
# spacing flag?
ignorews = int(request.form.get('ignorews', [0])[0])
_ = request.getText
# get a list of old revisions, and back out if none are available
currentpage = Page(request, pagename)
currentrev = currentpage.current_rev()
if currentrev < 2:
request.theme.add_msg(_("No older revisions available!"), "error")
currentpage.send_page()
return
if date: # this is how we get called from RecentChanges
rev1 = 0
log = editlog.EditLog(request, rootpagename=pagename)
for line in log.reverse():
if date >= line.ed_time_usecs and int(line.rev) != 99999999:
rev1 = int(line.rev)
break
else:
rev1 = 1
rev2 = 0
# Start output
# This action generates content in the user language
request.setContentLanguage(request.lang)
request.emit_http_headers()
request.theme.send_title(_('Diff for "%s"') % (pagename, ), pagename=pagename, allow_doubleclick=1)
if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
rev1, rev2 = rev2, rev1
if rev1 == -1:
oldrev = currentrev - 1
oldpage = Page(request, pagename, rev=oldrev)
elif rev1 == 0:
oldrev = currentrev
oldpage = currentpage
else:
oldrev = rev1
oldpage = Page(request, pagename, rev=oldrev)
if rev2 == 0:
newrev = currentrev
newpage = currentpage
else:
newrev = rev2
newpage = Page(request, pagename, rev=newrev)
edit_count = abs(newrev - oldrev)
f = request.formatter
request.write(f.div(1, id="content"))
oldrev = oldpage.get_real_rev()
newrev = newpage.get_real_rev()
revlist = currentpage.getRevList()
# code below assumes that the page exists and has at least
# one revision in the revlist, just bail out if not. Users
# shouldn't really run into this anyway.
if not revlist:
request.write(f.div(0)) # end content div
request.theme.send_footer(pagename)
request.theme.send_closing_html()
#.........这里部分代码省略.........