Revision a0abbade

b/snf-webproject/synnefo/webproject/manage.py
48 48
- override of --version command to display the snf-webproject version
49 49
"""
50 50

  
51
from django.core.management import ManagementUtility, setup_environ, \
51
from django.core.management import ManagementUtility, \
52 52
    BaseCommand, LaxOptionParser, handle_default_options, find_commands, \
53 53
    load_command_class
54 54

  
55 55
from django.core import management
56
from django.utils.importlib import import_module
57 56
from optparse import make_option
58 57
from synnefo.util.version import get_component_version
59 58
from synnefo.lib.dictconfig import dictConfig
......
174 173
        except (AttributeError, EnvironmentError, ImportError):
175 174
            apps = []
176 175

  
177
        # Find the project directory
178
        try:
179
            from django.conf import settings
180
            module = import_module(settings.SETTINGS_MODULE)
181
            project_directory = setup_environ(module, settings.SETTINGS_MODULE)
182
        except (AttributeError, EnvironmentError, ImportError, KeyError):
183
            project_directory = None
184

  
185 176
        # Find and load the management module for each installed app.
186 177
        for app_name in apps:
187 178
            try:
......
191 182
            except ImportError:
192 183
                pass  # No management module - ignore this app
193 184

  
194
        if project_directory:
185
        if apps:
195 186
            # Remove the "startproject" command from self.commands, because
196 187
            # that's a django-admin.py command, not a manage.py command.
197 188
            del _commands['startproject']
198 189

  
199
            # Override the startapp command so that it always uses the
200
            # project_directory, not the current working directory
201
            # (which is default).
202
            #from django.core.management.commands.startapp import ProjectCommand
203
            #_commands['startapp'] = ProjectCommand(project_directory)
204

  
205 190
    return _commands
206 191

  
207 192

  
......
343 328

  
344 329

  
345 330
def main():
346
    # no need to run setup_environ
347
    # we already know our project
348 331
    os.environ['DJANGO_SETTINGS_MODULE'] = \
349 332
        os.environ.get('DJANGO_SETTINGS_MODULE', 'synnefo.settings')
350 333
    configure_logging()

Also available in: Unified diff