Ejemplo n.º 1
0
 def render(self):
     self.nav_root = self.context.restrictedTraverse(
         getNavigationRoot(self.context))
     if ISubsite.providedBy(self.nav_root):
         return self.template()
     else:
         return ''
Ejemplo n.º 2
0
 def render(self):
     self.nav_root = self.context.restrictedTraverse(
         getNavigationRoot(self.context), None)
     if ISubsite.providedBy(self.nav_root):
         return self.template()
     else:
         return ''
Ejemplo n.º 3
0
    def getLanguage(self, langs, env):

        if not IFtwSubsiteLayer.providedBy(env):
            return base_negotiator.getLanguage(langs, env)

        # Get current published object
        obj = find_context(env)
        # Filter out CSS/JS and other non contentish objects
        # IFolderish check includes site root
        if not (IContentish.providedBy(obj) or IFolderish.providedBy(obj)):
            return base_negotiator.getLanguage(langs, env)

        nav_root = get_nav_root(obj)

        if ISubsite.providedBy(nav_root):
            # Get language stored on Subsite
            language = nav_root.force_language
            if language:
                return language
            else:
                return base_negotiator.getLanguage(langs, env)

        else:
            # Use normal Negotiator
            return base_negotiator.getLanguage(langs, env)
Ejemplo n.º 4
0
def get_subsite_language(request):
    """Returns None, or a language code."""
    if not IFtwSubsiteLayer.providedBy(request):
        return None

    # Get current published object
    obj = find_context(request)
    # Filter out CSS/JS and other non contentish objects
    # IFolderish check includes site root
    if not (IContentish.providedBy(obj) or IFolderish.providedBy(obj)):
        return None

    nav_root = get_nav_root(obj)

    if ISubsite.providedBy(nav_root):
        # Get language stored on Subsite
        language = nav_root.force_language
        if language:
            return language
        else:
            return None

    else:
        return None
Ejemplo n.º 5
0
 def get_subsite(self):
     nav_root = api.portal.get_navigation_root(self.context)
     if ISubsite.providedBy(nav_root):
         return dict(title=nav_root.Title(), url=nav_root.absolute_url())
     else:
         return None