Exemple #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.checkPermission(permission.title, self.context))
        return self.permission_cache[permission_name]
Exemple #2
0
    def __call__(self):
        result = super(SerializeFolderToJson, self).__call__()

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

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

        return result