'Check whether the current theme has a custom layout for this
class, and if so, store it in current.layouts
@param: the name of the custom layout
@return: the layout or None if not present'

@staticmethod
def get_layout(name):

    if hasattr(current, 'layouts'):
        layouts = current.layouts
    else:
        layouts = {}
    if (layouts is False):
        return None
    if (name in layouts):
        return layouts[name]
    application = current.request.application
    settings = current.deployment_settings
    theme = settings.get_theme()
    theme_location = current.response.s3.theme_location
    if theme_location:
        theme_location = ('%s.' % theme_location[:(-1)])
    package = ('applications.%s.modules.templates.%s%s.layouts' % (application, theme_location, theme))
    try:
        override = getattr(__import__(package, fromlist=[name]), name)
    except ImportError:
        current.layouts = False
        return None
    except AttributeError:
        override = None
    if (override and hasattr(override, 'layout') and (type(override.layout) == type((lambda : None)))):
        layout = override.layout
    else:
        layout = None
    layouts[name] = layout
    current.layouts = layouts
    return layout
