本文整理汇总了Python中MoinMoin.Page.Page.send_page方法的典型用法代码示例。如果您正苦于以下问题:Python Page.send_page方法的具体用法?Python Page.send_page怎么用?Python Page.send_page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.Page.Page
的用法示例。
在下文中一共展示了Page.send_page方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def render(self):
""" Redirect to the new page, using edit action and template """
error = self.checkAndCombineArguments() or self.checkPermissions()
if error:
# Send back to the page you came from, with an error msg
page = Page(self.request, self.referrer)
page.send_page(self.request, msg=error)
else:
# Redirect to new page using edit action. No error checking
# is needed because it is done later in new request.
pagename = self.pagename
query = {'action': 'edit', 'backto': self.referrer}
template = self.request.form.get('template', [''])[0]
if template:
from MoinMoin.wikiutil import quoteWikinameURL
query['template'] = quoteWikinameURL(template)
parent = self.request.form.get('parent', [''])[0]
if parent:
pagename = "%s/%s" % (parent, pagename)
url = Page(self.request, pagename).url(self.request, query, 0)
self.request.http_redirect(url)
raise MoinMoinNoFooter
return ''
示例2: _retrieve_members
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def _retrieve_members(self, group_name):
"""
MoinMoin.formatter.groups is used to extract group members from a page.
"""
formatter = Formatter(self.request)
page = Page(self.request, group_name, formatter=formatter)
request_page = getattr(self.request, "page", None)
self.request.page = page
# send_special is set to True because acl of the page should
# not be processed to avoid infinite recursion in the
# following case.
#
# Consider page UserGroup content:
#
# #acl UserGroup:read,write,admin All:read
#
# * ExampleUser
# * TestGroup
#
page.send_page(content_only=True, send_special=True)
if request_page:
self.request.page = request_page
else:
del self.request.page
return formatter.members
示例3: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def execute(macro, args):
_ = macro.request.getText
pagename = args or 'FortuneCookies'
if macro.request.user.may.read(pagename):
page = Page(macro.request, pagename)
raw = page.get_raw_body()
else:
raw = ""
# this selects lines looking like a list item
# !!! TODO: make multi-line quotes possible (optionally split by "----" or something)
quotes = raw.splitlines()
quotes = [quote.strip() for quote in quotes]
quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
if not quotes:
return (macro.formatter.highlight(1) +
_('No quotes on %(pagename)s.') % {'pagename': pagename} +
macro.formatter.highlight(0))
quote = random.choice(quotes)
page.set_raw_body(quote, 1)
out = StringIO.StringIO()
macro.request.redirect(out)
page.send_page(macro.request, content_only=1, content_id="RandomQuote_%s" % wikiutil.quoteWikinameFS(page.page_name) )
quote = out.getvalue()
macro.request.redirect()
return quote
示例4: __init__
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
class PackagePages:
def __init__(self, pagename, request):
self.request = request
self.pagename = pagename
self.page = Page(request, pagename)
def allowed(self):
""" Check if user is allowed to do this. """
return not self.__class__.__name__ in self.request.cfg.actions_excluded
def render(self):
""" Render action
This action returns a wiki page with optional message, or
redirects to new page.
"""
_ = self.request.getText
if 'cancel' in self.request.values:
# User canceled
return self.page.send_page()
try:
if not self.allowed():
self.request.theme.add_msg(_('You are not allowed to edit this page.'), "error")
raise ActionError
elif not self.page.exists():
self.request.theme.add_msg(_('This page is already deleted or was never created!'))
raise ActionError
self.package()
except ActionError, e:
return self.page.send_page()
示例5: render
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def render(self):
""" Redirect to the new page, using edit action and template """
error = self.checkAndCombineArguments() or self.checkPermissions()
if error:
# Send back to the page you came from, with an error msg
page = Page(self.request, self.referrer)
self.request.theme.add_msg(error, "error")
page.send_page()
else:
# Redirect to new page using edit action. No error checking
# is needed because it is done later in new request.
pagename = self.pagename
query = {'action': 'edit', 'backto': self.referrer}
template = self.request.form.get('template', [''])[0]
if template:
query['template'] = template
parent = self.request.form.get('parent', [''])[0]
if parent:
pagename = "%s/%s" % (parent, pagename)
url = Page(self.request, pagename).url(self.request, query)
self.request.http_redirect(url)
return ''
示例6: testSendPage
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def testSendPage(self):
page = Page(self.request, u"FrontPage")
import StringIO
out = StringIO.StringIO()
self.request.redirect(out)
page.send_page(msg=u'Done', emit_headers=False)
result = out.getvalue()
self.request.redirect()
del out
assert result.strip().endswith('</html>')
assert result.strip().startswith('<!DOCTYPE HTML PUBLIC')
示例7: get_members
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def get_members(self, text):
request = self.request
formatter = Formatter(self.request)
become_trusted(request)
create_page(request, u'TestPageGroup', text)
page = Page(request, 'TestPageGroup', formatter=formatter)
page.send_page(content_only=True)
nuke_page(request, u'TestPageGroup')
return formatter.members
示例8: sidebar
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def sidebar(self, d):
""" Assemble wiki sidebar """
name = u'サイドバー'
page = Page(self.request, name)
if not page.exists():
return u''
buff = StringIO()
self.request.redirect(buff)
page.send_page(content_only=1)
self.request.redirect()
return u'<div id="sidebar">%s</div>' % buff.getvalue()
示例9: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def execute(pagename, request):
_ = request.getText
page = Page(request, pagename)
if request.user.may.read(pagename):
badwords, badwords_re, msg = checkSpelling(page, request)
else:
badwords = []
msg = _("You can't check spelling on a page you can't read.")
if badwords:
page.send_page(request, msg=msg, hilite_re=badwords_re)
else:
page.send_page(request, msg=msg)
示例10: __init__
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
class LoginHandler:
def __init__(self, pagename, request):
self.request = request
self._ = request.getText
self.cfg = request.cfg
self.pagename = pagename
self.page = Page(request, pagename)
def handle(self):
_ = self._
request = self.request
form = request.form
error = None
islogin = form.get('login', [''])[0]
if islogin: # user pressed login button
return self.page.send_page(request, msg=error)
else: # show login form
request.http_headers()
wikiutil.send_title(request, _("Login"), pagename=self.pagename)
# Start content (important for RTL support)
request.write(request.formatter.startContent("content"))
request.write(userform.getLogin(request))
# End content and send footer
request.write(request.formatter.endContent())
wikiutil.send_footer(request, self.pagename)
示例11: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def execute(pagename, request):
found = False
for auth in request.cfg.auth:
if isinstance(auth, MoinAuth):
found = True
break
if not found:
# we will not have linked, so forbid access
request.makeForbidden(403, 'No MoinAuth in auth list')
return
page = Page(request, pagename)
_ = request.getText
form = request.form
submitted = form.has_key('create')
if submitted: # user pressed create button
request.theme.add_msg(_create_user(request), "dialog")
return page.send_page()
else: # show create form
request.theme.send_title(_("Create Account"), pagename=pagename)
request.write(request.formatter.startContent("content"))
# THIS IS A BIG HACK. IT NEEDS TO BE CLEANED UP
request.write(_create_form(request))
request.write(request.formatter.endContent())
request.theme.send_footer(pagename)
request.theme.send_closing_html()
示例12: main
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def main():
args = parseOptions()
tmpdir = None
cwd = os.getcwd()
try:
if args.directory is None:
tmpdir = tempfile.mkdtemp()
create_temp_wiki(args, args.page, tmpdir)
args.page = "SomePage"
# Needed so relative paths in configuration are found
os.chdir(args.directory)
# Needed to load configuration
sys.path = [ os.getcwd(), ] + sys.path
url = re.sub("%", re.escape(args.page), args.url_template)
if MOIN_VERSION >= "1.9":
from MoinMoin.web.contexts import ScriptContext as Request
else:
from MoinMoin.request.request_cli import Request
class MyRequest(Request):
def normalizePagename(self, name):
return name
def normalizePageURL(self, name, url):
return args.url_template.replace('%', name)
request = MyRequest(url=url, pagename=args.page)
Formatter = wikiutil.importPlugin(request.cfg, "formatter",
"text_x-rst", "Formatter")
formatter = Formatter(request)
request.formatter = formatter
page = Page(request, args.page, rev=args.revision, formatter=formatter)
if not page.exists():
raise RuntimeError("No page named %r" % ( args.page, ))
page.send_page()
finally:
if tmpdir is not None:
shutil.rmtree(tmpdir)
os.chdir(cwd)
示例13: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def execute(pagename, request):
_ = request.getText
if not request.user.may.admin(pagename):
thispage = Page(request, pagename)
request.theme.add_msg(_("You are not allowed to perform this action."), "error")
return thispage.send_page()
elif 'users' not in request.form:
show_form(pagename, request)
else:
show_result(pagename, request)
示例14: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def execute(pagename, request):
"""
save images to attachments
"""
#TODO add auth control
_ = request.getText
page = Page(request, pagename)
image2attach = Image2Attach(pagename, request)
image2attach.process()
request.theme.add_msg(
_(
"Images saved successful: %d, Failed: %d" % (
image2attach.process_success,
image2attach.process_fail,
)
),
"info"
)
page.send_page()
示例15: execute
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import send_page [as 别名]
def execute(pagename, request):
from MoinMoin import wikiutil
from MoinMoin.Page import Page
_ = request.getText
thispage = Page(request, pagename)
siocPage = "SiocSpecTemplate"
specPath = "/var/www/html/spec/"
specURL = "http://sparql.captsolo.net/spec/"
if pagename != siocPage:
return thispage.send_page(request,
msg = _('This action only works for SIOC template.'))
# 1) get template (HTML)
# = page contents
template = thispage.get_raw_body()
myMsg = '<p><b>Regenerated SIOC specification the template.</b></p>'
# 2) run SpecGen code
import sys
sys.path.insert(0, specPath)
import specgen4
specgen4.setTermDir( specPath+'doc' )
spec = specgen4.main( 'http://sw.deri.org/svn/sw/2005/08/sioc/ns/sioc', template )
# 3) save file
#
file = open( specPath+'sioc.html', 'wt' )
file.write(spec.encode('utf-8'))
file.close()
# 5) display message - OK
myMsg += '<p>Check it out: <b><a href="' + specURL + '">SIOC specification</a></b> [draft]</p><p> </p>'
return thispage.send_page(request,
msg = _(myMsg))