コード例 #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()
コード例 #2
0
ファイル: action.py プロジェクト: smcmahon/ploneintranet
 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)
コード例 #3
0
ファイル: action.py プロジェクト: kombinat/ploneintranet
 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)
コード例 #4
0
ファイル: layers.py プロジェクト: sudhan77/ploneintranet
    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)
コード例 #5
0
ファイル: layers.py プロジェクト: affinitic/ploneintranet
    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)