Import the object given by clsname.
    If default_module is specified, import from this module.

def import_obj(clsname, default_module=None):
    """
    Import the object given by clsname.
    If default_module is specified, import from this module.
    """
    if default_module is not None:
        if not clsname.startswith(default_module + '.'):
            clsname = '{0}.{1}'.format(default_module, clsname)
    mod, clsname = clsname.rsplit('.', 1)
    mod = importlib.import_module(mod)
    try:
        obj = getattr(mod, clsname)
    except AttributeError:
        raise ImportError('Cannot import {0} from {1}'.format(clsname, mod))
    return obj