Example #1
0
def install_app(name=None, conf=None):
    """
    Install django application (settings and urls).

    'app_conf_path' may be presented as:
        * Python module (regular *.py file)
        * Python package (that should contain 'settings.py' inside)
          If it also contains 'urls.py' - this module will be added to the 'URLS_TO_INSTALL' setting

    Conventions:
        * If there is setting named "ignore" and it's bool == True, then installation will be cancelled.
        * See more conventions in the "install_settings" docs - help(install_settings)
    """

    sys.stdout.write(smart_str('Installing "%s" ...\n' % conf))

    if conf:
        try:
            conf_module = get_module(conf)
        except ImportError:
            sys.stderr.write(
                smart_str('Error: can\'t import "%s" module.' % conf))
            sys.exit(1)

        # App conf may be a package or a module
        if '__init__.py' in conf_module.__file__:
            # Get app settings
            app_settings = '.'.join([conf, 'settings'])
            try:
                app_settings = get_module(app_settings)
            except ImportError:
                app_settings = None

            # Get app urls
            app_urls = '.'.join([conf, 'urls'])
            try:
                imp.find_module('urls', conf_module.__path__)
            except ImportError:
                app_urls = None
        else:
            app_settings = conf_module
            app_urls = None

        if app_settings:
            if getattr(app_settings, 'ignore', False):
                sys.stdout.write(
                    smart_str('... "%s" installation ignored.\n' % conf))
            else:
                install_settings(app_settings)

        if app_urls:
            # Postpone for further urls install
            append_setting('URLS_TO_INSTALL', app_urls)

    if name:
        append_setting('INSTALLED_APPS', name)
Example #2
0
def install_app(name=None, conf=None):
    """
    Install django application (settings and urls).

    'app_conf_path' may be presented as:
        * Python module (regular *.py file)
        * Python package (that should contain 'settings.py' inside)
          If it also contains 'urls.py' - this module will be added to the 'URLS_TO_INSTALL' setting

    Conventions:
        * If there is setting named "ignore" and it's bool == True, then installation will be cancelled.
        * See more conventions in the "install_settings" docs - help(install_settings)
    """

    sys.stdout.write(smart_str('Installing "%s" ...\n' % conf))

    if conf:
        try:
            conf_module = get_module(conf)
        except ImportError:
            sys.stderr.write(smart_str('Error: can\'t import "%s" module.' % conf))
            sys.exit(1)

        # App conf may be a package or a module
        if '__init__.py' in conf_module.__file__:
            # Get app settings
            app_settings = '.'.join([conf, 'settings'])
            try:
                app_settings = get_module(app_settings)
            except ImportError:
                app_settings = None

            # Get app urls
            app_urls = '.'.join([conf, 'urls'])
            try:
                imp.find_module('urls', conf_module.__path__)
            except ImportError:
                app_urls = None
        else:
            app_settings = conf_module
            app_urls = None

        if app_settings:
            if getattr(app_settings, 'ignore', False):
                sys.stdout.write(smart_str('... "%s" installation ignored.\n' % conf))
            else:
                install_settings(app_settings)

        if app_urls:
            # Postpone for further urls install
            append_setting('URLS_TO_INSTALL', app_urls)

    if name:
        append_setting('INSTALLED_APPS', name)
Example #3
0
# -*- encoding:utf-8 -*-
"""
Common web-app settings
"""
from project.utils.settings import append_setting

append_setting('STATICFILES_FINDERS', 'conf.apps.web.staticfinders.StaticRootFinder')
append_setting('INTERNAL_IPS', ('127.0.0.1', 'localhost'))
# -*- encoding:utf-8 -*-
"""
Common web-app settings
"""
from project.utils.settings import append_setting

append_setting('STATICFILES_FINDERS',
               'conf.apps.web.staticfinders.StaticRootFinder')
append_setting('INTERNAL_IPS', ('127.0.0.1', 'localhost'))