def execute(self): """ Given the command-line arguments, this figures out which subcommand is being run, creates a parser appropriate to that command, and runs it. Taken from django execute method, but enabling all active plugins before execution. """ # Preprocess options to extract --settings and --pythonpath. # These options could affect the commands that are available, so they # must be processed early. parser = django_management.LaxOptionParser( usage="%prog subcommand [options] [args]", version=django_management.get_version(), option_list=BaseCommand.option_list) try: options, args = parser.parse_args(self.argv) handle_default_options(options) except: pass # Ignore any option errors at this point. try: subcommand = self.argv[1] except IndexError: sys.stderr.write("Type '%s help' for usage.\n" % self.prog_name) sys.exit(1) if subcommand == 'help': if len(args) > 2: self.fetch_command(args[2]).print_help(self.prog_name, args[2]) else: parser.print_lax_help() sys.stderr.write(self.main_help_text() + '\n') sys.exit(1) # Special-cases: We want 'django-admin.py --version' and # 'django-admin.py --help' to work, for backwards compatibility. elif self.argv[1:] == ['--version']: # LaxOptionParser already takes care of printing the version. pass elif self.argv[1:] == ['--help']: parser.print_lax_help() sys.stderr.write(self.main_help_text() + '\n') else: command = self.fetch_command(subcommand) if subcommand not in [ 'migrate', 'syncdb', 'startproject', 'dbshell', 'rebuild_db', 'restore_config', 'schemamigration', 'datamigration', 'backupdb', 'startplugin' ]: # This is override fragment of Django execute method # only works if models have been created (not with syncdb, startproject neither migrate) from merengue.pluggable import enable_active_plugins enable_active_plugins() command.run_from_argv(self.argv)
def execute(self): """ Given the command-line arguments, this figures out which subcommand is being run, creates a parser appropriate to that command, and runs it. Taken from django execute method, but enabling all active plugins before execution. """ # Preprocess options to extract --settings and --pythonpath. # These options could affect the commands that are available, so they # must be processed early. parser = django_management.LaxOptionParser(usage="%prog subcommand [options] [args]", version=django_management.get_version(), option_list=BaseCommand.option_list) try: options, args = parser.parse_args(self.argv) handle_default_options(options) except: pass # Ignore any option errors at this point. try: subcommand = self.argv[1] except IndexError: sys.stderr.write("Type '%s help' for usage.\n" % self.prog_name) sys.exit(1) if subcommand == 'help': if len(args) > 2: self.fetch_command(args[2]).print_help(self.prog_name, args[2]) else: parser.print_lax_help() sys.stderr.write(self.main_help_text() + '\n') sys.exit(1) # Special-cases: We want 'django-admin.py --version' and # 'django-admin.py --help' to work, for backwards compatibility. elif self.argv[1:] == ['--version']: # LaxOptionParser already takes care of printing the version. pass elif self.argv[1:] == ['--help']: parser.print_lax_help() sys.stderr.write(self.main_help_text() + '\n') else: command = self.fetch_command(subcommand) if subcommand not in ['migrate', 'syncdb', 'startproject', 'dbshell', 'rebuild_db', 'restore_config', 'schemamigration', 'datamigration', 'backupdb', 'startplugin']: # This is override fragment of Django execute method # only works if models have been created (not with syncdb, startproject neither migrate) from merengue.pluggable import enable_active_plugins enable_active_plugins() command.run_from_argv(self.argv)
def post_migrate_handler(sender, **kwargs): from merengue.pluggable import enable_active_plugins global post_save_receivers, cache_backend app = kwargs['app'] if is_last_application(app): enable_active_plugins() # site fixtures loading after migration for app_name, fixtures in getattr(settings, 'SITE_FIXTURES', {}).items(): if app_name == app: # only migrate for fixture in fixtures: call_command('loaddata', fixture, verbosity=1) # will set again saved receivers and cache backend post_save.receivers = post_save_receivers settings.CACHES['default']['BACKEND'] = cache_backend