当前位置: 首页>>代码示例>>Python>>正文


Python module_loading.import_module方法代码示例

本文整理汇总了Python中django.utils.module_loading.import_module方法的典型用法代码示例。如果您正苦于以下问题:Python module_loading.import_module方法的具体用法?Python module_loading.import_module怎么用?Python module_loading.import_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.module_loading的用法示例。


在下文中一共展示了module_loading.import_module方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_crud

# 需要导入模块: from django.utils import module_loading [as 别名]
# 或者: from django.utils.module_loading import import_module [as 别名]
def import_crud(app):
    '''
    Import crud module and register all model cruds which it contains
    '''

    try:
        app_path = import_module(app).__path__
    except (AttributeError, ImportError):
        return None

    try:
        imp.find_module('crud', app_path)
    except ImportError:
        return None

    module = import_module("%s.crud" % app)

    return module 
开发者ID:asifpy,项目名称:django-crudbuilder,代码行数:20,代码来源:helpers.py

示例2: __init__

# 需要导入模块: from django.utils import module_loading [as 别名]
# 或者: from django.utils.module_loading import import_module [as 别名]
def __init__(self, method = 'GET'):
        super(EnhancedHttpRequest, self).__init__()
        self.method = method

        session_engine = import_module(settings.SESSION_ENGINE)
        self.session = session_engine.SessionStore(session_key = None) 
开发者ID:hspandher,项目名称:django-test-addons,代码行数:8,代码来源:utils.py

示例3: create_session

# 需要导入模块: from django.utils import module_loading [as 别名]
# 或者: from django.utils.module_loading import import_module [as 别名]
def create_session(self):
        session_engine = import_module(settings.SESSION_ENGINE)
        store = session_engine.SessionStore()
        store.save()
        self.client.cookies[settings.SESSION_COOKIE_NAME] = store.session_key 
开发者ID:hspandher,项目名称:django-test-addons,代码行数:7,代码来源:utils.py

示例4: register_builtin_plugins

# 需要导入模块: from django.utils import module_loading [as 别名]
# 或者: from django.utils.module_loading import import_module [as 别名]
def register_builtin_plugins(site):
    from django.conf import settings
    from django.utils.module_loading import import_module

    exclude_plugins = getattr(settings, 'XADMIN_EXCLUDE_PLUGINS', [])

    try:
        import formtools
    except Exception:
        exclude_plugins.append('wizard')

    [import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins] 
开发者ID:madre,项目名称:devops,代码行数:14,代码来源:__init__.py

示例5: get_session_app

# 需要导入模块: from django.utils import module_loading [as 别名]
# 或者: from django.utils.module_loading import import_module [as 别名]
def get_session_app():
    engine = import_module(settings.SESSION_ENGINE)
    store = engine.SessionStore
    if hasattr(store, "get_model_class"):
        session_model = store.get_model_class()
        if issubclass(session_model, AbstractBaseSession):
            return session_model._meta.app_config.name
    return None 
开发者ID:lorinkoz,项目名称:django-pgschemas,代码行数:10,代码来源:checks.py

示例6: autodiscover

# 需要导入模块: from django.utils import module_loading [as 别名]
# 或者: from django.utils.module_loading import import_module [as 别名]
def autodiscover():
    """
    Auto-discover INSTALLED_APPS admin.py modules and fail silently when
    not present. This forces an import on them to register any admin bits they
    may want.
    """

    from django.conf import settings
    from django.utils.module_loading import module_has_submodule, import_module

    setattr(settings, 'CRISPY_TEMPLATE_PACK', 'bootstrap3')
    setattr(settings, 'CRISPY_CLASS_CONVERTERS', {
        "textinput": "textinput textInput form-control",
        "fileinput": "fileinput fileUpload form-control",
        "passwordinput": "textinput textInput form-control",
    })

    from xadmin.views import register_builtin_views
    register_builtin_views(site)

    # load xadmin settings from XADMIN_CONF module
    try:
        xadmin_conf = getattr(settings, 'XADMIN_CONF', 'xadmin_conf.py')
        conf_mod = import_module(xadmin_conf)
    except Exception:
        conf_mod = None

    if conf_mod:
        for key in dir(conf_mod):
            setting = getattr(conf_mod, key)
            try:
                if issubclass(setting, Settings):
                    site.register_settings(setting.__name__, setting)
            except Exception:
                pass

    from xadmin.plugins import register_builtin_plugins
    register_builtin_plugins(site)

    from django.apps import apps
    
    for app_config in apps.get_app_configs():
        # Attempt to import the app's admin module.
        try:
            before_import_registry = site.copy_registry()
            import_module('%s.adminx' % app_config.name)
        except:
            # Reset the model registry to the state before the last import as
            # this import will have to reoccur on the next request and this
            # could raise NotRegistered and AlreadyRegistered exceptions
            # (see #8245).
            site.restore_registry(before_import_registry)

            # Decide whether to bubble up this error. If the app just
            # doesn't have an admin module, we can ignore the error
            # attempting to import it, otherwise we want it to bubble up.
            if module_has_submodule(app_config.module, 'adminx'):
                raise 
开发者ID:madre,项目名称:devops,代码行数:60,代码来源:__init__.py


注:本文中的django.utils.module_loading.import_module方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。