本文整理汇总了Python中MoinMoin.PageEditor.PageEditor.sendEditor方法的典型用法代码示例。如果您正苦于以下问题:Python PageEditor.sendEditor方法的具体用法?Python PageEditor.sendEditor怎么用?Python PageEditor.sendEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.PageEditor.PageEditor
的用法示例。
在下文中一共展示了PageEditor.sendEditor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_event
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import sendEditor [as 别名]
#.........这里部分代码省略.........
end_day = self._get_input(form, "end-day", start_day)
end_month = self._get_input(form, "end-month", start_month)
end_year = self._get_input(form, "end-year", start_year)
except (TypeError, ValueError):
return 0, _("Days and years must be numbers yielding a valid date!")
try:
start_hour = self._get_input(form, "start-hour")
start_minute = self._get_input(form, "start-minute")
start_second = self._get_input(form, "start-second")
end_hour = self._get_input(form, "end-hour")
end_minute = self._get_input(form, "end-minute")
end_second = self._get_input(form, "end-second")
except (TypeError, ValueError):
return 0, _("Hours, minutes and seconds must be numbers yielding a valid time!")
start_date = DateTime(
(start_year, start_month, start_day, start_hour, start_minute, start_second, start_zone)
)
start_date.constrain()
end_date = DateTime(
(end_year, end_month, end_day, end_hour, end_minute, end_second, end_zone)
)
end_date.constrain()
# An elementary date ordering check.
if (start_date.as_date() != end_date.as_date() or start_date.has_time() and end_date.has_time()) and start_date > end_date:
start_date, end_date = end_date, start_date
event_details = {
"start" : str(start_date), "end" : str(end_date),
"title" : title, "summary" : title,
"description" : description, "location" : location, "link" : link,
"topics" : [topic for topic in topics if topic]
}
if latitude and longitude:
event_details["geo"] = latitude, longitude
# Copy the template.
template_page = PageEditor(request, template)
if not template_page.exists():
return 0, _("Event template not available.")
# Use any parent page information.
full_title = getFullPageName(parent, title)
if page_name:
# Allow parameters in the page name. This permits a degree of
# interoperability with MonthCalendar.
page_name = page_name.replace("@[email protected]", request.page.page_name)
page_name = page_name.replace("@[email protected]", str(start_date.as_date()))
page_name = page_name.replace("@[email protected]", str(start_date.as_date()))
page_name = page_name.replace("@[email protected]", str(end_date.as_date()))
page_name = page_name.replace("@[email protected]", parent)
page_name = page_name.replace("@[email protected]", title)
# Normalise any page hierarchy separators.
page_name = re.sub("/+", "/", page_name)
else:
page_name = full_title
# Load the new page and replace the event details in the body.
new_page = PageEditor(request, page_name)
if new_page.exists():
return 0, _("The specified page already exists. Please choose another name.")
# Complete the new page and return its body.
body = fillEventPageFromTemplate(template_page, new_page, event_details, category_pagenames)
# Open the page editor on the new page.
# NOTE: Replacing the revision in the request to prevent Moin from
# NOTE: attempting to use the queued changes page's revision.
# NOTE: Replacing the action and page in the request to avoid issues
# NOTE: with editing tickets.
request.rev = 0
request.action = "edit"
request.page = new_page
new_page.sendEditor(preview=body, staytop=True)
# Return success.
return 1, None
示例2: do_savepage
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import sendEditor [as 别名]
def do_savepage(pagename, request):
from MoinMoin.PageEditor import PageEditor
_ = request.getText
if not request.user.may.write(pagename):
Page(request, pagename).send_page(request,
msg = _('You are not allowed to edit this page.'))
return
pg = PageEditor(request, pagename)
savetext = request.form.get('savetext', [u''])[0]
rev = int(request.form.get('rev', ['0'])[0])
comment = request.form.get('comment', [u''])[0]
category = request.form.get('category', [None])[0]
rstrip = int(request.form.get('rstrip', ['0'])[0])
trivial = int(request.form.get('trivial', ['0'])[0])
# IMPORTANT: normalize text from the form. This should be done in
# one place before we manipulate the text.
savetext = pg.normalizeText(savetext, stripspaces=rstrip)
# Add category
# TODO: this code does not work with extended links, and is doing
# things behind your back, and in general not needed. Either we have
# a full interface for categories (add, delete) or just add them by
# markup.
if category:
# strip trailing whitespace
savetext = savetext.rstrip()
# Add category separator if last non-empty line contains
# non-categories.
lines = filter(None, savetext.splitlines())
if lines:
#TODO: this code is broken, will not work for extended links
#categories, e.g ["category hebrew"]
categories = lines[-1].split()
if categories:
confirmed = wikiutil.filterCategoryPages(request, categories)
if len(confirmed) < len(categories):
# This was not a categories line, add separator
savetext += u'\n----\n'
# Add new category
if savetext and savetext[-1] != u'\n':
savetext += ' '
savetext += category + u'\n' # Should end with newline!
# Clean comment - replace CR, LF, TAB by whitespace, delete control chars
# TODO: move this to config, create on first call then return cached.
remap_chars = {
ord(u'\t'): u' ',
ord(u'\r'): u' ',
ord(u'\n'): u' ',
}
control_chars = u'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f' \
'\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'
for c in control_chars:
remap_chars[c] = None
comment = comment.translate(remap_chars)
# Preview, spellcheck or spellcheck add new words
if (request.form.has_key('button_preview') or
request.form.has_key('button_spellcheck') or
request.form.has_key('button_newwords')):
pg.sendEditor(preview=savetext, comment=comment)
# Edit was canceled
elif request.form.has_key('button_cancel'):
pg.sendCancel(savetext, rev)
# Save new text
else:
try:
savemsg = pg.saveText(savetext, rev, trivial=trivial,
comment=comment)
except pg.EditConflict, msg:
# Handle conflict and send editor
# TODO: conflict messages are duplicated from PageEditor,
# refactor to one place only.
conflict_msg = _('Someone else changed this page while you were editing!')
pg.set_raw_body(savetext, modified=1)
if pg.mergeEditConflict(rev):
conflict_msg = _("""Someone else saved this page while you were editing!
Please review the page and save then. Do not save this page as it is!
Have a look at the diff of %(difflink)s to see what has been changed.""") % {
'difflink': pg.link_to(pg.request,
querystr='action=diff&rev=%d' % rev)
}
# We don't send preview when we do merge conflict
pg.sendEditor(msg=conflict_msg, comment=comment)
return
else:
savemsg = conflict_msg
#.........这里部分代码省略.........