• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ptah.check_permission函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ptah.check_permission函数的典型用法代码示例。如果您正苦于以下问题:Python check_permission函数的具体用法?Python check_permission怎么用?Python check_permission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: cmsContent

def cmsContent(request, app, uri=None, action='', *args):
    info = {}

    appfactory = ptah.cms.get_app_factories().get(app)
    if appfactory is None:
        raise NotFound()

    root = appfactory(request)
    request.root = root

    if not uri:
        content = root
    else:
        content = load(uri)

    adapters = config.registry.adapters

    action = adapters.lookup(
        (IRestActionClassifier, providedBy(content)),
        IRestAction, name=action, default=None)

    if action:
        request.environ['SCRIPT_NAME'] = '%s/content:%s/'%(
            request.environ['SCRIPT_NAME'], app)

        ptah.check_permission(action.permission, content, request, True)
        res = action.callable(content, request, *args)
        if not res: # pragma: no cover
            res = {}
        return res

    raise NotFound()
开发者ID:blaflamme,项目名称:ptah,代码行数:32,代码来源:rest.py


示例2: test_checkpermission_deny

    def test_checkpermission_deny(self):
        import ptah

        content = Content(acl=[(Allow, ptah.Everyone.id, ALL_PERMISSIONS)])

        self.assertTrue(ptah.check_permission("View", content, throw=False))
        self.assertFalse(ptah.check_permission(ptah.NOT_ALLOWED, content, throw=False))
开发者ID:WouterVH,项目名称:ptah,代码行数:7,代码来源:test_security.py


示例3: test_checkpermission_allow

    def test_checkpermission_allow(self):
        import ptah

        content = Content(acl=[DENY_ALL])

        self.assertFalse(ptah.check_permission("View", content, throw=False))
        self.assertTrue(ptah.check_permission(NO_PERMISSION_REQUIRED, content, throw=False))
开发者ID:WouterVH,项目名称:ptah,代码行数:7,代码来源:test_security.py


示例4: test_checkpermission_user

    def test_checkpermission_user(self):
        import ptah

        content = Content(acl=[(Allow, 'test-user', 'View')])
        self.assertFalse(ptah.check_permission('View', content, throw=False))

        ptah.auth_service.set_userid('test-user')
        self.assertTrue(ptah.check_permission('View', content, throw=False))
开发者ID:runyaga,项目名称:ptah,代码行数:8,代码来源:test_security.py


示例5: test_checkpermission_superuser

    def test_checkpermission_superuser(self):
        import ptah
        from pyramid import security

        content = Content(acl=[(Deny, ptah.SUPERUSER_URI, security.ALL_PERMISSIONS)])

        ptah.authService.set_userid(ptah.SUPERUSER_URI)
        self.assertTrue(ptah.check_permission("View", content))
        self.assertFalse(ptah.check_permission(ptah.NOT_ALLOWED, content))
开发者ID:WouterVH,项目名称:ptah,代码行数:9,代码来源:test_security.py


示例6: test_checkpermission_authenticated

    def test_checkpermission_authenticated(self):
        import ptah

        content = Content(acl=[(Allow, ptah.Authenticated.id, "View")])

        self.assertFalse(ptah.check_permission("View", content, throw=False))

        ptah.authService.set_userid("test-user")
        self.assertTrue(ptah.check_permission("View", content, throw=False))
开发者ID:WouterVH,项目名称:ptah,代码行数:9,代码来源:test_security.py


示例7: test_checkpermission_local_roles

    def test_checkpermission_local_roles(self):
        import ptah

        content = Content(iface=ptah.ILocalRolesAware, acl=[(Allow, "role:test", "View")])

        ptah.authService.set_userid("test-user")
        self.assertFalse(ptah.check_permission("View", content, throw=False))

        content.__local_roles__["test-user"] = ["role:test"]
        self.assertTrue(ptah.check_permission("View", content, throw=False))
开发者ID:WouterVH,项目名称:ptah,代码行数:10,代码来源:test_security.py


示例8: test_checkpermission_local_roles

    def test_checkpermission_local_roles(self):
        import ptah

        content = Content(
            iface=ptah.ILocalRolesAware,
            acl=[(Allow, 'role:test', 'View')])

        ptah.auth_service.set_userid('test-user')
        self.assertFalse(ptah.check_permission('View', content, throw=False))

        content.__local_roles__['test-user'] = ['role:test']
        self.assertTrue(ptah.check_permission('View', content, throw=False))
开发者ID:runyaga,项目名称:ptah,代码行数:12,代码来源:test_security.py


示例9: containerNodeInfo

def containerNodeInfo(content, request, *args):
    """Container information"""
    info = nodeInfo(content, request)

    contents = []
    for item in content.values():
        if not ptah.check_permission(View, item, request): # pragma: no cover
            continue

        contents.append(
            OrderedDict((
                    ('__name__', item.__name__),
                    ('__type__', item.__type_id__),
                    ('__uri__', item.__uri__),
                    ('__container__', isinstance(item, Container)),
                    ('__link__', '%s%s/'%(request.application_url,
                                          item.__uri__)),
                    ('title', item.title),
                    ('description', item.description),
                    ('created', item.created),
                    ('modified', item.modified),
                    )))

    info['__contents__'] = contents
    return info
开发者ID:WouterVH,项目名称:ptah,代码行数:25,代码来源:rest.py


示例10: is_allowed

    def is_allowed(self, container):
        if not isinstance(container, Container):
            return False

        if self.permission:
            return ptah.check_permission(self.permission, container)
        return True
开发者ID:WouterVH,项目名称:ptah,代码行数:7,代码来源:tinfo.py


示例11: update

    def update(self):
        context = self.context
        request = self.request
        registry = request.registry

        self.deleteContent = ptah.check_permission(
            cms.DeleteContent, context)

        # cms(uri).read()
        # cms(uri).create(type)
        # cms(uri).delete()
        # cms(uri).update(**kwargs)
        # cms(uri).items(offset, limit)

        if self.deleteContent and 'form.buttons.remove' in request.POST:
            uris = self.request.POST.getall('item')
            for uri in uris:
                cms.wrap(uri).delete()

                self.message("Selected content items have been removed.")

        if 'form.buttons.rename' in request.POST:
            uris = self.request.POST.getall('item')
            print '=============', uris

        if 'form.buttons.cut' in request.POST:
            uris = self.request.POST.getall('item')
            print '=============', uris
开发者ID:ptahproject,项目名称:devel,代码行数:28,代码来源:views.py


示例12: get_protocol

    def get_protocol(self, name, _marker=object()):
        protocol = self.protocols.get(name)

        if protocol is None:
            item = self.registry.adapters.lookup(
                (providedBy(self),), IProtocol, name=name)
            if item is not None:
                factory, permission = item
            else:
                factory, permission = None, None

            # permission
            if permission:
                if not ptah.check_permission(
                    permission, self.request.context, self.request):
                    factory = None
                    self.protocols[name] = component = _marker
                    log.warning("Permission check failed for %s"%name)

            if factory is not None:
                # shared storage
                storage = self.manager.storage.get(name)
                if storage is None:
                    storage = {}
                    self.manager.storage[name] = storage

                # create
                protocol = factory(self, storage)
                protocol.__name__ = name
                protocol.request = self.request
                protocol.on_open()
                self.protocols[name] = protocol

        return protocol if protocol is not _marker else None
开发者ID:webmaven,项目名称:ptah,代码行数:34,代码来源:session.py


示例13: check

    def check(self, context, request):
        if self.permission:
            if not ptah.check_permission(
                self.permission, context, request):
                return False

        if self.condition is not None:
            return self.condition(context, request)

        return True
开发者ID:webmaven,项目名称:ptah,代码行数:10,代码来源:uiactions.py


示例14: __getattr__

    def __getattr__(self, action):
        if not self._actions or action not in self._actions:
            raise NotFound(action)

        fname, permission = self._actions[action]
        if permission:
            if not ptah.check_permission(permission, self._content):
                raise Forbidden(action)

        return ActionWrapper(self._content, fname)
开发者ID:WouterVH,项目名称:ptah,代码行数:10,代码来源:security.py


示例15: cmsContent

def cmsContent(request, app='', uri=None, action='', *args):
    name = getattr(request, 'subpath', ('content',))[0]
    if ':' not in name:
        if not action:
            action = uri or ''
        uri = app
        app = u''

    content = None

    appfactory = ptah.cms.get_app_factories().get(app)
    if appfactory is not None:
        root = appfactory(request)
        request.root = root

        if not uri:
            content = root

    if content is None:
        content = load(uri)

    adapters = request.registry.adapters

    action = adapters.lookup(
        (IRestActionClassifier, providedBy(content)),
        IRestAction, name=action, default=None)

    if action:
        if app:
            request.environ['SCRIPT_NAME'] = '%s/content:%s/'%(
                request.environ['SCRIPT_NAME'], app)
        else:
            request.environ['SCRIPT_NAME'] = '%s/content/'%(
                request.environ['SCRIPT_NAME'])

        ptah.check_permission(action.permission, content, request, True)
        res = action.callable(content, request, *args)
        if not res: # pragma: no cover
            res = {}
        return res

    raise NotFound()
开发者ID:WouterVH,项目名称:ptah,代码行数:42,代码来源:rest.py


示例16: contents

    def contents(self):
        """ Returns public or viewable content of the container """

        contents = []
        
        for content in self.values():
            if IContent.providedBy(content):
                if content.public or ptah.check_permission(View, content):
                    contents.append(content)

        return contents
开发者ID:djedproject,项目名称:ptahcms,代码行数:11,代码来源:container.py


示例17: apidocAction

def apidocAction(content, request, *args):
    """api doc"""
    actions = []
    url = request.application_url
    for name, action in request.registry.adapters.lookupAll(
        (IRestActionClassifier, providedBy(content)), IRestAction):

        if not ptah.check_permission(
            action.permission, content, request):
            continue

        actions.append(
            (name, action.title,
             OrderedDict(
                    (('name', name or 'info'),
                     ('link', '%s%s/%s'%(url, content.__uri__, name)),
                     ('title', action.title),
                     ('description', action.description)))))

    return [action for _t, _n, action in sorted(actions)]
开发者ID:runyaga,项目名称:ptah,代码行数:20,代码来源:rest.py


示例18: load

def load(uri, permission=None):
    """ Load node by `uri` and initialize __parent__ attributes. Also checks
    permission if permissin is specified.

    :param uri: Node uri
    :param permission: Check permission on node object
    :type permission: Permission id or None
    :raise KeyError: Node with this uri is not found.
    :raise Forbidden: If current principal doesn't pass permission check on loaded node.
    """
    item = ptah.resolve(uri)

    if item is not None:
        load_parents(item)

        if permission is not None:
            if not ptah.check_permission(permission, item):
                raise Forbidden()
    else:
        raise NotFound(uri)

    return item
开发者ID:blaflamme,项目名称:ptah,代码行数:22,代码来源:node.py


示例19: is_allowed

 def is_allowed(self, container):
     if self.permission:
         return ptah.check_permission(self.permission, container)
     return True
开发者ID:carlicos,项目名称:ptah,代码行数:4,代码来源:typeinfo.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ptah.get_session函数代码示例发布时间:2022-05-25
下一篇:
Python compat.register函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap