'Helper function to load a response.s3 variable from models'

@classmethod
def get(cls, name, default=None):

    s3 = current.response.s3
    if (s3 is None):
        s3 = current.response.s3 = Storage()
    if (name in s3):
        return s3[name]
    elif ('_' in name):
        prefix = name.split('_', 1)[0]
        models = current.models
        if hasattr(models, prefix):
            module = models.__dict__[prefix]
            loaded = False
            generic = []
            for n in module.__all__:
                model = module.__dict__[n]
                if (type(model).__name__ == 'type'):
                    if loaded:
                        continue
                    if hasattr(model, 'names'):
                        if (name in model.names):
                            model(prefix)
                            loaded = True
                            generic = []
                        else:
                            continue
                    else:
                        generic.append(n)
                elif n.startswith(('%s_' % prefix)):
                    s3[n] = model
            [module.__dict__[n](prefix) for n in generic]
    if (name in s3):
        return s3[name]
    elif isinstance(default, Exception):
        raise default
    else:
        return default
