def set_application(self, application, force_creation=False, verbose_creation=True): """ Called when the application for this Migrations is set. Imports the migrations module object, and throws a paddy if it can't. """ if isinstance(application, six.string_types): if application in sys.modules: application = sys.modules[application] else: application = app_label_to_app_module(application) self._application = application if not hasattr(application, 'south_migrations'): try: module = self.migrations_module() self._migrations = application.south_migrations = module except ImportError: if force_creation: self.create_migrations_directory(verbose_creation) module = self.migrations_module() self._migrations = application.south_migrations = module else: six.reraise(exceptions.NoMigrations, exceptions.NoMigrations(application)) if hasattr(application, 'south_migrations'): self._load_migrations_module(application.south_migrations)
def set_application(self, application, force_creation=False, verbose_creation=True): """ Called when the application for this Migrations is set. Imports the migrations module object, and throws a paddy if it can't. """ if isinstance(application, six.string_types): if application in sys.modules: application = sys.modules[application] else: application = app_label_to_app_module(application) self._application = application if not hasattr(application, "south_migrations"): try: module = self.migrations_module() self._migrations = application.south_migrations = module except ImportError: if force_creation: self.create_migrations_directory(verbose_creation) module = self.migrations_module() self._migrations = application.south_migrations = module else: six.reraise(exceptions.NoMigrations, exceptions.NoMigrations(application)) if hasattr(application, "south_migrations"): self._load_migrations_module(application.south_migrations)
def __call__(self, application, **kwds): app_label = application_to_app_label(application) # If we don't already have an instance, make one if app_label not in self.instances: self.instances[app_label] = super(MigrationsMetaclass, self).__call__(app_label_to_app_module(app_label), **kwds) return self.instances[app_label]
def __call__(self, application, **kwds): app_label = application_to_app_label(application) # If we don't already have an instance, make one if app_label not in self.instances: self.instances[app_label] = super(MigrationsMetaclass, self).__call__(app_label_to_app_module(app_label), **kwds) return self.instances[app_label]