Esempio n. 1
0
    def check_permission(self, permission_name):
        if permission_name is None:
            return True

        if permission_name not in self.permission_cache:
            permission = queryUtility(IPermission,
                                      name=permission_name)
            if permission is None:
                self.permission_cache[permission_name] = True
            else:
                security = IInteraction(self.request)
                self.permission_cache[permission_name] = bool(
                    security.check_permission(permission.title, self.context))
        return self.permission_cache[permission_name]
Esempio n. 2
0
    def __call__(self):
        result = super(SerializeFolderToJson, self).__call__()

        security = IInteraction(self.request)
        length = len(self.context)

        if length > MAX_ALLOWED or length == 0:
            result['items'] = []
        else:
            result['items'] = [
                getMultiAdapter(
                    (member, self.request), IResourceSerializeToJsonSummary)()
                for ident, member in self.context.items()
                if not ident.startswith('_') and
                bool(security.check_permission(
                    'plone.AccessContent', self.context))
            ]
        result['length'] = length

        return result