本文整理汇总了Python中trac.wiki.model.WikiPage.page_exist方法的典型用法代码示例。如果您正苦于以下问题:Python WikiPage.page_exist方法的具体用法?Python WikiPage.page_exist怎么用?Python WikiPage.page_exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.wiki.model.WikiPage
的用法示例。
在下文中一共展示了WikiPage.page_exist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import page_exist [as 别名]
def process_request(self, req):
action = req.args.get('action', 'view')
pagename = req.args.get('page', 'WikiStart')
version = req.args.get('version')
old_version = req.args.get('old_version')
if pagename.endswith('/'):
req.redirect(req.href.wiki(pagename.strip('/')))
page = WikiPage(self.env, pagename)
versioned_page = WikiPage(self.env, pagename, version=version)
page.permission_v=self._perm_v_list(pagename,req)
page.permission_w=self._perm_w_list(pagename,req)
versioned_page.permission_v=self._perm_v_list(pagename,req)
versioned_page.permission_w=self._perm_w_list(pagename,req)
req.perm(page.resource).require('WIKI_VIEW')
req.perm(versioned_page.resource).require('WIKI_VIEW')
page.admin_or_creator="TRAC_ADMIN" in req.perm or self._is_the_creator(pagename,req.authname,req)==True
versioned_page.admin_or_creator="TRAC_ADMIN" in req.perm or self._is_the_creator(pagename,req.authname,req)==True
page.edit_perm=self._has_edit_perm(page.name,req.authname,req)
versioned_page.edit_perm=self._has_edit_perm(page.name,req.authname,req)
page.page_exist=self._exist_in_wiki(pagename,req)
versioned_page.page_exist=self._exist_in_wiki(pagename,req)
if self._has_view_perm(page.name,req.authname,req)==False:
raise ResourceNotFound(
_('You are not authorized to view this page!'))
if version and versioned_page.version != int(version):
raise ResourceNotFound(
_('No version "%(num)s" for Wiki page "%(name)s"',
num=version, name=page.name))
add_stylesheet(req, 'common/css/wiki.css')
if req.method == 'POST':
if action == 'edit':
if 'cancel' in req.args:
req.redirect(req.href.wiki(page.name))
permission_v=req.args.get("permission_v","")
permission_w=req.args.get("permission_w","")
self._update_wikipermission_v(pagename,permission_v,req)
self._update_wikipermission_w(pagename,permission_w,req)
has_collision = int(version) != page.version
for a in ('preview', 'diff', 'merge'):
if a in req.args:
action = a
break
versioned_page.text = req.args.get('text')
valid = self._validate(req, versioned_page)
if action == 'edit' and not has_collision and valid:
return self._do_save(req, versioned_page)
else:
return self._render_editor(req, page, action, has_collision)
elif action == 'delete':
self._do_delete(req, versioned_page)
elif action == 'rename':
return self._do_rename(req, page)
elif action == 'diff':
style, options, diff_data = get_diff_options(req)
contextall = diff_data['options']['contextall']
req.redirect(req.href.wiki(versioned_page.name, action='diff',
old_version=old_version,
version=version,
contextall=contextall or None))
elif action == 'delete':
return self._render_confirm_delete(req, versioned_page)
elif action == 'rename':
return self._render_confirm_rename(req, page)
elif action == 'edit':
if self._has_edit_perm(page.name,req.authname,req)==False:
raise ResourceNotFound(_('You are not authorized to edit this page!'))
return self._render_editor(req, versioned_page)
elif action == 'diff':
return self._render_diff(req, versioned_page)
elif action == 'history':
return self._render_history(req, versioned_page)
else:
format = req.args.get('format')
if format:
Mimeview(self.env).send_converted(req, 'text/x-trac-wiki',
versioned_page.text,
format, versioned_page.name)
return self._render_view(req, versioned_page)