Changeset 5966


Ignore:
Timestamp:
22 Apr 2011, 11:26:35 (14 years ago)
Author:
uli
Message:

Use a default theme if the name set on a University instance cannot be found.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py

    r5961 r5966  
    1414from waeup.sirp.interfaces import IWAeUPObject
    1515from waeup.sirp.browser.interfaces import ITheme
    16 from waeup.sirp.browser.theming import get_all_themes
     16from waeup.sirp.browser.theming import get_all_themes, WAeUPThemeGray1
    1717
    1818grok.templatedir('templates')
     
    9999    grok.context(IWAeUPObject)
    100100
     101    #: An instance of the default theme to use for the site layout
     102    default_theme = WAeUPThemeGray1()
     103
    101104    @property
    102105    def site(self):
     
    127130
    128131    def update(self):
    129         theme_name = getattr(grok.getSite(), 'skin', 'gray waeup theme')
    130         theme = getUtility(ITheme, name=theme_name)
     132        """Include the resources required by the chosen skin/theme.
     133
     134        University instances provide a 'skin' attribute, that should
     135        hold the internal name of a theme.
     136
     137        A theme in the waeup.sirp sense consists of a list of
     138        CSS/JavaScript resources defined in the
     139        :mod:`waeup.sirp.browser.resources` module.
     140
     141        If the context University object has no such attribute or the
     142        set value is not a valid theme name, we pick 'gray waeup
     143        theme' as default.
     144        """
     145        theme_name = getattr(grok.getSite(), 'skin', '')
     146        theme = queryUtility(ITheme, name=theme_name,
     147                             default=self.default_theme)
    131148        for resource in theme.getResources():
    132149            resource.need()
Note: See TracChangeset for help on using the changeset viewer.