def __bobo_traverse__(self, request, name):
        """
        If no subobject is found through Folder API
        then try to lookup the object by invoking getDocumentValue
    """
        # Register current web site physical path for later URL generation
        if request.get(self.web_section_key, MARKER) is MARKER:
            request[self.web_section_key] = self.getPhysicalPath()
            # Normalize web parameter in the request
            # Fix common user mistake and transform '1' string to boolean
            for web_param in ['ignore_layout', 'editable_mode']:
                if hasattr(request, web_param):
                    param = getattr(request, web_param, None)
                    if isinstance(param, (list, tuple)):
                        param = param[0]
                    if param in ('1', 1, True):
                        request.set(web_param, True)
                    else:
                        request.set(web_param, False)

        document = None
        try:
            document = DocumentExtensibleTraversableMixin.__bobo_traverse__(
                self, request, name)
        except NotFound:
            not_found_page_ref = self.getLayoutProperty(
                'layout_not_found_page_reference')
            if not_found_page_ref:
                document = DocumentExtensibleTraversableMixin.getDocumentValue(
                    self, name=not_found_page_ref)
            if document is None:
                # if no document found, fallback on default page template
                document = DocumentExtensibleTraversableMixin.__bobo_traverse__(
                    self, request, '404.error.page')
        return document
    def getExtensibleContent(self, request, name):
        stack = request['TraversalRequestNameStack']

        if isinstance(name, list):
            name = name[0]
        if not name or name in ("/", ):
            url_list = []
        else:
            url_list = [name]
        while len(stack):
            if stack[-1] not in ('/', ''):
                url_list.append(stack.pop())
            else:
                stack.pop()

        # Drop the automatically added VirtualHostMonster object ID
        virtual_url_part_tuple = request.get('VIRTUAL_URL_PARTS', None)
        if (virtual_url_part_tuple is not None) and \
           (not urllib.unquote(virtual_url_part_tuple[-1]).endswith("/".join(url_list))):
            url_list.pop(0)

        if request.get('ACTUAL_URL',
                       '').endswith("/"):  # or len(url_list) == 0:
            url_list.append("index.html")

        return DocumentExtensibleTraversableMixin.getExtensibleContent(
            self, request, "/".join(url_list))
Beispiel #3
0
 def getExtensibleContent(self, request, name):
   # Be sure that html conversion is done,
   # as it is required to extract extensible content
   old_manager, user = self._forceIdentification(request)
   web_cache_kw = {'name': name,
                   'format': EMBEDDED_FORMAT}
   try:
     self._convert(format='html')
     view = _ViewEmulator().__of__(self)
     # If we have a conditional get, set status 304 and return
     # no content
     if _checkConditionalGET(view, web_cache_kw):
       return ''
     # call caching policy manager.
     _setCacheHeaders(view, web_cache_kw)
     mime, data = self.getConversion(format=EMBEDDED_FORMAT, filename=name)
     document = OFSFile(name, name, data, content_type=mime).__of__(self.aq_parent)
   except (NotConvertedError, ConversionError, KeyError):
     document = DocumentExtensibleTraversableMixin.getExtensibleContent(self, request, name)
   # restore original security context if there's a logged in user
   if user is not None:
     setSecurityManager(old_manager)
   return document