当前位置: 首页>>代码示例>>Python>>正文


Python WikiPage.permission_v方法代码示例

本文整理汇总了Python中trac.wiki.model.WikiPage.permission_v方法的典型用法代码示例。如果您正苦于以下问题:Python WikiPage.permission_v方法的具体用法?Python WikiPage.permission_v怎么用?Python WikiPage.permission_v使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.wiki.model.WikiPage的用法示例。


在下文中一共展示了WikiPage.permission_v方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_request

# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import permission_v [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)
开发者ID:zjj,项目名称:trac_hack,代码行数:88,代码来源:web_ui.py


注:本文中的trac.wiki.model.WikiPage.permission_v方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。