Python django.utils.module_loading 模块,import_module() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用django.utils.module_loading.import_module()

项目:plugs-mail    作者:solocompt    | 项目源码 | 文件源码
def get_apps(self):
        """
        Get the list of installed apps
        and return the apps that have
        an emails module
        """
        templates = []
        for app in settings.INSTALLED_APPS:
            try:
                app = import_module(app + '.emails')
                templates += self.get_plugs_mail_classes(app)
            except ImportError:
                pass
        return templates
项目:stormtrooper    作者:CompileInc    | 项目源码 | 文件源码
def get_channel_routings():
    channel_routing = []
    for app in settings.INSTALLED_APPS:
        try:
            routing = import_module("{}.routing".format(app))
            channel_routing.extend(routing.channel_routing)
        except:
            continue
    return channel_routing
项目:pinax-notifications-backends    作者:psychok7    | 项目源码 | 文件源码
def get_class_from_path(path):
    # This function is helpful to avoid circular imports.
    module_name, class_name = path.rsplit(".", 1)
    class_ = getattr(import_module(module_name), class_name)
    return class_
项目:djangoevents    作者:ApplauseOSS    | 项目源码 | 文件源码
def import_app_module(app_module_name, module_name):
    full_module_name = '%s.%s' % (app_module_name, module_name)
    try:
        import_module(full_module_name)
    except ImportError:
        # we need to re-raise exception in case there was import error inside
        # `module_name` module
        module_file_name = get_module_file_name(app_module_name, module_name)
        if os.path.exists(module_file_name):
            raise
项目:djangoevents    作者:ApplauseOSS    | 项目源码 | 文件源码
def get_module_file_name(app_module_name, module_name):
    module = import_module(app_module_name)
    module_dir = os.path.dirname(module.__file__)
    return os.path.join(module_dir, '%s.py' % module_name)
项目:django_mc    作者:team23    | 项目源码 | 文件源码
def autodiscover():
    for app in settings.INSTALLED_APPS:
        mod = import_module(app)
        try:
            import_module('%s.%s' % (app, 'link_resolvers'))
        except:
            if module_has_submodule(mod, 'link_resolvers'):
                raise