本文整理汇总了Python中MoinMoin.PageEditor.PageEditor.user方法的典型用法代码示例。如果您正苦于以下问题:Python PageEditor.user方法的具体用法?Python PageEditor.user怎么用?Python PageEditor.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.PageEditor.PageEditor
的用法示例。
在下文中一共展示了PageEditor.user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import user [as 别名]
def execute(pagename, request):
form = values_to_form(request.values)
template = form.get('template', [''])[0]
if template and not request.page.exists():
template_page = wikiutil.unquoteWikiname(template)
if request.user.may.read(template_page):
editor = PageEditor(request, template_page)
editor.user = request.user
text = editor.get_raw_body()
editor.page_name = pagename
request.page.set_raw_body(editor._expand_variables(text))
newdata = parse_text(request, request.page,
request.page.get_raw_body())
# Add prototype metas (^ something::\s*$) as keys
protokeys = [y for x,y in dl_proto_re.findall(text)]
for key in protokeys:
if not (key in newdata[pagename].get('out', dict()) or
key in newdata[pagename].get('meta', dict())):
newdata[pagename].setdefault('meta', dict())[key] = list()
# I'll lie, cheat, do anything to make this work
newdata[pagename]['saved'] = True
# Add the template metas to cache so that they'd show
request.graphdata.cacheset(pagename, newdata.get(pagename, dict()))
MetaEdit.execute(pagename, request)
示例2: execute
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import user [as 别名]
def execute(pagename, request):
_ = request.getText
form = values_to_form(request.values)
if not request.user.may.write(pagename):
request.reset()
backto = form.get('backto', [None])[0]
if backto:
request.page = Page(request, backto)
request.theme.add_msg(_('You are not allowed to edit this page.'),
"error")
request.page.send_page()
return
frm = wr(
u'<form id="metaformedit" method="POST" enctype="multipart/form-data" action="%s">\n',
actionname(request))+\
wr(u'<input form="metaformedit" type="hidden" name="action" value="MetaEdit">\n')+\
wr(u'<input form="metaformedit" type="hidden" name="gwikiseparator" value="%s">\n',
SEPARATOR)
btn = '<div class="saveform"><p class="savemessage">' + \
wr('<input type=submit name=saveform form="metaformedit" value="%s">',
_(form.get('saveBtnText', ['Save Changes'])[0])) + \
wr('<input form="metaformedit" type=submit name=cancel value="%s">',
_('Cancel')) +'</p></div>'
# Template to use for any new pages
template = form.get('template', [''])[0]
if template:
frm += wr('<input form="metaformedit" type="hidden" name="template" value="%s">', template)
# Where to after saving page
backto = form.get('backto', [''])[0]
if backto:
frm += wr('<input form="metaformedit" type="hidden" name="backto" value="%s">', backto)
old_header = request.cfg.page_header2
old_footer = request.cfg.page_footer1
# The post-header and pre-footer texts seem to be implemented in themes.
# Using post-header instead of page msg to avoid breaking header forms.
request.cfg.page_header2 += frm + btn
request.cfg.page_footer1 += btn + '</form>'
old_page = request.page
request.page = FormPage(request, pagename)
error = ''
newpage = False
template_text = ''
# If the page does not exist but we'd know how to construct it,
# replace the Page content with template and pretend it exists
if template and not request.page.exists():
template_page = wikiutil.unquoteWikiname(template)
if request.user.may.read(template_page):
editor = PageEditor(request, template_page)
editor.user = request.user
text = editor.get_raw_body()
editor.page_name = pagename
template_text = editor._expand_variables(text)
request.page.set_raw_body(template_text)
request.page.exists = lambda **kw: True
request.page.lastEditInfo = lambda: {}
newpage = True
else:
error = '<div class="saveform"><p class="savemessage">' + \
_("Cannot read template") + '</p></div>'
elif not template and not request.page.exists():
error = '<div class="saveform"><p class="savemessage">' + \
_("No template specified, cannot edit") + '</p></div>'
if error:
request.cfg.page_header2 = request.cfg.page_header2 + error
request.cfg.page_footer1 = request.cfg.page_footer1
# Extra spaces from formatter need to be removed, that's why the
# page is not sent as it is
out = StringIO.StringIO()
request.redirect(out)
request.sent_headers = True
request.page.send_page()
request.redirect()
graphdata = request.graphdata
vals_on_keys = graphdata.get_vals_on_keys()
# If we're making a new page based on a template, make sure that
# the values from the evaluated template are included in the form editor
if newpage:
templatePage = Page(request, template)
data = parse_text(request, templatePage, template_text)
for page in data:
for key in data[page].get('meta', list()):
for val in data[page]['meta'][key]:
vals_on_keys.setdefault(key, set()).add(val)
for key in data[page].get('out', list()):
for val in data[page]['out'][key]:
#.........这里部分代码省略.........