Example #1
0
    def getChildWithDefault(self, segment, request):

        if not segment:
            return Redirect(request.childLink('index'))

        renderFunc = self.getRenderFunc(segment)
        if renderFunc is not None:
            self.facetName = segment
            self.renderFunc = renderFunc
            self.isLeaf = True

            # Perform an additional check before rendering the response
            if not access.allowed(request.avatar, self.node, facetName=segment):
                return AccessDenied()
            response = self.getResponse(request)

            # Int is for NOT_DONE_YET. Maybe we should
            # check for a resource, rather than this?
            if isinstance(response, (str, int)):
                self.response = response
                return self
            else:
                return response

        subNode = self.getSubNode(segment)
        if subNode is not None:
            if not access.allowed(request.avatar, subNode):
                return AccessDenied()
            return NodeResource(subNode)

        return NoResource()
Example #2
0
    def getChildWithDefault(self, segment, request):

        if not segment:
            return Redirect(request.childLink('index'))

        renderFunc = self.getRenderFunc(segment)
        if renderFunc is not None:
            self.facetName = segment
            self.renderFunc = renderFunc
            self.isLeaf = True

            # Perform an additional check before rendering the response
            if not access.allowed(request.avatar, self.node,
                                  facetName=segment):
                return AccessDenied()
            response = self.getResponse(request)

            # Int is for NOT_DONE_YET. Maybe we should
            # check for a resource, rather than this?
            if isinstance(response, (str, int)):
                self.response = response
                return self
            else:
                return response

        subNode = self.getSubNode(segment)
        if subNode is not None:
            if not access.allowed(request.avatar, subNode):
                return AccessDenied()
            return NodeResource(subNode)

        return NoResource()
Example #3
0
    def getChildWithDefault(self, firstSegment, request):

        if firstSegment:
            fp = self.buildFilePath(request)
            if fp is not None:
                del request.postpath[:]
                return static.File(fp.path)

        # Init for everything except static files
        session = request.getSession()
        request.avatar = session.avatar

        if config.get("reloadMessages"):
            translate.loadMessages()

        request.translateTerm = translate.getTranslator(session.language)

        handler = self.dispatch.get(firstSegment)

        if handler is not None:
            return handler(request)

        node = helpers.getNode(firstSegment)

        if node is not None:
            if not access.allowed(request.avatar, node):
                return AccessDenied()
            return NodeResource(node)

        return NoResource()
Example #4
0
    def getChildWithDefault(self, firstSegment, request):

        if firstSegment:
            fp = self.buildFilePath(request)
            if fp is not None:
                del request.postpath[:]
                return static.File(fp.path)

        # Init for everything except static files
        session = request.getSession()
        request.avatar = session.avatar

        getRequestStore = config.get('getRequestStore')
        if getRequestStore is not None:
            request.store = getRequestStore(request)
        else:
            request.store = avatar_store

        if request.avatar is not None:
            getUser = config.get('getRequestUser')
            if getUser is not None:
                request.avatar.user = getUser(request)
            else:
                # Backward compatibility
                getUser = config.get('getAppUser')
                if getUser is not None:
                    warnings.warn(
                        "getAppUser is deprecated, use getRequestUser instead",
                        DeprecationWarning)
                    request.avatar.user = getUser(request.avatar)

        if config.get('reloadMessages'):
            translate.loadMessages()

        request.translateTerm = translate.getTranslator(session.language)

        segment = firstSegment
        if self.caseInsensitiveUrl:
            segment = firstSegment.lower()
        handler = self.dispatch.get(segment)

        if handler is not None:
            return handler(request)

        node = helpers.getNode(firstSegment)

        if node is not None:
            if not access.allowed(request.avatar, node):
                return AccessDenied()
            return NodeResource(node)

        return NoResource()
Example #5
0
    def getChildWithDefault(self, firstSegment, request):

        if firstSegment:
            fp = self.buildFilePath(request)
            if fp is not None:
                del request.postpath[:]
                return static.File(fp.path)

        # Init for everything except static files
        session = request.getSession()
        request.avatar = session.avatar

        getRequestStore = config.get('getRequestStore')
        if getRequestStore is not None:
            request.store = getRequestStore(request)
        else:
            request.store = avatar_store

        if request.avatar is not None:
            getUser = config.get('getRequestUser')
            if getUser is not None:
                request.avatar.user = getUser(request)
            else:
                # Backward compatibility
                getUser = config.get('getAppUser')
                if getUser is not None:
                    warnings.warn("getAppUser is deprecated, use getRequestUser instead",
                                  DeprecationWarning)
                    request.avatar.user = getUser(request.avatar)

        if config.get('reloadMessages'):
            translate.loadMessages()

        request.translateTerm = translate.getTranslator(session.language)


        segment = firstSegment
        if self.caseInsensitiveUrl:
            segment = firstSegment.lower()
        handler = self.dispatch.get(segment)

        if handler is not None:
            return handler(request)

        node = helpers.getNode(firstSegment)

        if node is not None:
            if not access.allowed(request.avatar, node):
                return AccessDenied()
            return NodeResource(node)

        return NoResource()