def load_middleware(app, name, mwconfig):
    log.info('Loading WSGI middleware %s' % name)
    try:
        modulename, wsgi = name.rsplit('.', 1)
        mw = __import__(modulename)
        mw = sys.modules[modulename]
        mw = getattr(mw, wsgi, None)
        if mw is None or not callable(mw):
            log.error('No callable named %s in %s (%r)' % (wsgi, modulename, mw))
        else:
            app = mw(app, **mwconfig)
    except Exception:
        log.exception('Unable to load WSGI middleware %s' % name)
    return app
dataset/ETHPy150Open uber/clay/clay/server.py/load_middleware/original