Esempio n. 1
0
def filter_request(site, event):
    """Remove browser layer(s) and bundles when needed.
    Called on INavigationRoot traversal.
    """
    # avoid sites where this product is not installed
    if IThemeSwitcher.providedBy(event.request):
        # delegate to policy adapter above
        ISwitchableThemingPolicy(event.request).filter_request()
Esempio n. 2
0
 def __call__(self):
     """Redirect between default and fallback hosts.
     Note that this is not protocol aware, so you'll have
     to run either both on http or both on https."""
     policy = theming_policy(self.request)
     if ISwitchableThemingPolicy.providedBy(self.request):
         log.error("@@switch_theme invoked but no switchable policy")
         return "@@switch_theme invoked but no switchable policy"
     switcher = policy.getSwitcherSettings()
     current = self.context.absolute_url()
     default_host = switcher.hostname_default or u'localhost'
     fallback_host = switcher.hostname_switchlist[0]
     if policy.isFallbackActive():
         target = current.replace(fallback_host, default_host)
     else:
         target = current.replace(default_host, fallback_host)
     self.request.response.redirect(target)
Esempio n. 3
0
 def __call__(self):
     """Redirect between default and fallback hosts.
     Note that this is not protocol aware, so you'll have
     to run either both on http or both on https."""
     policy = theming_policy(self.request)
     if ISwitchableThemingPolicy.providedBy(self.request):
         log.error("@@switch_theme invoked but no switchable policy")
         return "@@switch_theme invoked but no switchable policy"
     switcher = policy.getSwitcherSettings()
     current = self.context.absolute_url()
     default_host = switcher.hostname_default or u'localhost'
     fallback_host = switcher.hostname_switchlist[0]
     if policy.isFallbackActive():
         target = current.replace(fallback_host, default_host)
     else:
         target = current.replace(default_host, fallback_host)
     if self.url_append:
         target = "/".join((target, self.url_append))
     self.request.response.redirect(target)
Esempio n. 4
0
    def __call__(self, context, request):
        if request.get("ploneintranet.layout.app.enabled"):
            return
        # manipulate the same request only once, and only for one app
        request.set("ploneintranet.layout.app.enabled", True)

        app_layers = list(context.app_layers)

        # do not undo themeswitching
        policy = theming_policy(request)
        if ISwitchableThemingPolicy.providedBy(policy) and policy.isFallbackActive():  # only applies to Barceloneta
            switcher = policy.getSwitcherSettings()
            # respect themeswitching blacklist
            remove_layers = [resolveDottedName(x) for x in switcher.browserlayer_filterlist]
            # enable only non-blacklisted IAppLayers
            app_layers = [x for x in app_layers if x not in remove_layers]

        active_layers = app_layers + get_layers(request)
        directlyProvides(request, *active_layers)
Esempio n. 5
0
    def __call__(self, context, request):
        if request.get('ploneintranet.layout.app.enabled'):
            return
        # manipulate the same request only once, and only for one app
        request.set('ploneintranet.layout.app.enabled', True)

        app_layers = list(context.app_layers)

        # do not undo themeswitching
        policy = theming_policy(request)
        if ISwitchableThemingPolicy.providedBy(policy) \
           and policy.isFallbackActive():  # only applies to Barceloneta
            switcher = policy.getSwitcherSettings()
            # respect themeswitching blacklist
            remove_layers = [
                resolveDottedName(x) for x in switcher.browserlayer_filterlist
            ]
            # enable only non-blacklisted IAppLayers
            app_layers = [x for x in app_layers if x not in remove_layers]

        active_layers = app_layers + get_layers(request)
        directlyProvides(request, *active_layers)