本文整理汇总了Python中MoinMoin.PageEditor.PageEditor.revertPage方法的典型用法代码示例。如果您正苦于以下问题:Python PageEditor.revertPage方法的具体用法?Python PageEditor.revertPage怎么用?Python PageEditor.revertPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.PageEditor.PageEditor
的用法示例。
在下文中一共展示了PageEditor.revertPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xmlrpc_revertPage
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import revertPage [as 别名]
def xmlrpc_revertPage(self, pagename, revision):
"""
Revert a page to previous revision
This is mainly intended to be used by the jabber bot.
@param pagename: the page name (unicode or utf-8)
@param revision: revision to revert to
@rtype: bool
@return: True on success
"""
pagename = self._instr(pagename)
if not self.request.user.may.write(pagename):
return xmlrpclib.Fault(1, "You are not allowed to edit this page")
rev = int(self._instr(revision))
editor = PageEditor(self.request, pagename, do_editor_backup=0)
try:
editor.revertPage(rev)
except PageEditor.SaveError, error:
return xmlrpclib.Fault(1, "Revert failed: %s" % (str(error), ))
示例2: do_action
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import revertPage [as 别名]
def do_action(self):
""" revert pagename """
form = self.form
comment = form.get('comment', [u''])[0]
comment = wikiutil.clean_input(comment)
if self.request.request_method != 'POST':
return False, u''
rev = self.request.rev
pg = PageEditor(self.request, self.pagename)
try:
msg = pg.revertPage(rev, comment)
# make it show the current version...
self.request.rev = None
except PageEditor.RevertError, error:
msg = unicode(error)