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


Python Page.may方法代码示例

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


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

示例1: _check

# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import may [as 别名]
def _check(request, pagename, username, right):
    """ Check <right> access permission for user <username> on page <pagename>

    For cfg.acl_hierarchic=False we just check the page in question.

    For cfg.acl_hierarchic=True we, we check each page in the hierarchy. We
    start with the deepest page and recurse to the top of the tree.
    If one of those permits, True is returned.

    For both configurations, we check acl_rights_before before the page/default
    acl and acl_rights_after after the page/default acl, of course.

    This method should not be called by users, use __getattr__ instead.

    @param request: the current request object
    @param pagename: pagename to get permissions from
    @param username: the user name
    @param right: the right to check

    @rtype: bool
    @return: True if you have permission or False
    """
    cache = request.cfg.cache
    allowed = cache.acl_rights_before.may(request, username, right)
    if allowed is not None:
        return allowed

    if request.cfg.acl_hierarchic:
        pages = pagename.split('/') # create page hierarchy list
        some_acl = False
        for i in range(len(pages), 0, -1):
            # Create the next pagename in the hierarchy
            # starting at the leaf, going to the root
            name = '/'.join(pages[:i])
            # Get page acl and ask for permission
            acl = Page(request, name).getACL(request)
            if acl.acl:
                some_acl = True
                allowed = acl.may(request, username, right)
                if allowed is not None:
                    return allowed
        if not some_acl:
            allowed = cache.acl_rights_default.may(request, username, right)
            if allowed is not None:
                return allowed
    else:
        if request.page is not None and pagename == request.page.page_name:
            p = request.page # reuse is good
        else:
            p = Page(request, pagename)
        acl = p.getACL(request) # this will be fast in a reused page obj
        allowed = acl.may(request, username, right)
        if allowed is not None:
            return allowed

    allowed = cache.acl_rights_after.may(request, username, right)
    if allowed is not None:
        return allowed

    return False
开发者ID:steveyen,项目名称:moingo,代码行数:62,代码来源:__init__.py


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