def _on_request_1(self, event, request, response, peer_cert=None):
        """
        First request handler. This handler handles resource requests
        directed at the portal or a portlet.
        """
        if not self._is_portal_request(request):
            return

        if peer_cert:
            event.peer_cert = peer_cert
            
        # Decode query parameters and body
        event.kwargs = parse_qs(request.qs)
        parse_body(request, response, event.kwargs)
        session = request.session
        # Is this a portal portal request?
        if request.path.startswith(self._portal_resource):
            res = os.path.join(os.path.join\
                (self._portal_resource_dir, 
                 request.path[len(self._portal_resource):]))
            if os.path.exists(res):
                event.stop()
                return tools.serve_file(request, response, res)
            return
        # Is this a portal theme resource request?
        if request.path.startswith(self._theme_resource):
            for directory in self._portal._templates_dir:
                res = os.path.join \
                    (directory, "themes", 
                     ThemeSelection.selected(session), 
                     request.path[len(self._theme_resource):])
                if os.path.exists(res):
                    event.stop()
                    return tools.serve_file(request, response, res)
            return
        # Is this a portlet resource request?
        if request.path.startswith(self._portlet_resource):
            segs = request.path[len(self._portlet_resource):].split("/")
            if len(segs) >= 2:
                request.path = "/".join(segs[1:])
                event.kwargs.update\
                    ({ "theme": ThemeSelection.selected(session),
                       "locales": LanguagePreferences.preferred(session)})
                return self.fire (portlet_resource(*event.args, 
                                                   **event.kwargs), segs[0])
Beispiel #2
0
    def _on_request_1(self, event, request, response, peer_cert=None):
        """
        First request handler. This handler handles resource requests
        directed at the portal or a portlet.
        """
        if not self._is_portal_request(request):
            return

        if peer_cert:
            event.peer_cert = peer_cert
            
        # Decode query parameters and body
        event.kwargs = parse_qs(request.qs)
        parse_body(request, response, event.kwargs)
        session = request.session
        # Is this a portal portal request?
        if request.path.startswith(self._portal_resource):
            res = os.path.join(os.path.join\
                (self._portal_resource_dir, 
                 request.path[len(self._portal_resource):]))
            if os.path.exists(res):
                event.stop()
                return tools.serve_file(request, response, res)
            return
        # Is this a portal theme resource request?
        if request.path.startswith(self._theme_resource):
            for directory in self._portal._templates_dir:
                res = os.path.join \
                    (directory, "themes", 
                     ThemeSelection.selected(session), 
                     request.path[len(self._theme_resource):])
                if os.path.exists(res):
                    event.stop()
                    return tools.serve_file(request, response, res)
            return
        # Is this a portlet resource request?
        if request.path.startswith(self._portlet_resource):
            segs = request.path[len(self._portlet_resource):].split("/")
            if len(segs) >= 2:
                request.path = "/".join(segs[1:])
                event.kwargs.update\
                    ({ "theme": ThemeSelection.selected(session),
                       "locales": LanguagePreferences.preferred(session)})
                return self.fire (portlet_resource(*event.args, 
                                                   **event.kwargs), segs[0])
 def __init__(self, portal_view, session):
     self._session = session
     self._portal_view = portal_view
     self._portal = portal_view.portal
     self._theme = ThemeSelection.selected(session)
     self._tabs = portal_view.tab_manager(session).tabs