Skip to content

AmsdalManager

AmsdalManager is a toplevel class to manage your application, connections, integrations, data and migrations:

  • build
  • apply migrations
  • initiate connections
  • teardown

amsdal.manager.AmsdalManager

Bases: amsdal.mixins.build_mixin.BuildMixin, amsdal.mixins.class_versions_mixin.ClassVersionsMixin

Manages the AMSDAL framework components and operations.

This class is responsible for initializing, setting up, and managing various components of the AMSDAL framework, including connections, data management, schema management, and authentication. It also provides methods for building and tearing down the framework.

__init__ method descriptor

__init__(*, raise_on_new_signup=False)

Initializes all sub managers. Reads the configuration.

Returns: None

is_authenticated property

is_authenticated

Indicates if the AMSDAL license authentication process has been passed.

This property returns a boolean value indicating whether the AMSDAL license authentication process has been successfully completed.

Returns: bool: True if authenticated, False otherwise.

pre_setup method descriptor

pre_setup()

Initiates models root path and adds it into sys.path.

This method initializes the class manager and sets up the models root path as specified in the settings. It ensures that the models root path is added to the system path for proper module resolution.

Returns: None

setup method descriptor

setup()

Initiates models root path and the connections.

This method sets up the AMSDAL framework by initializing the models root path and establishing connections. It ensures that the setup process is only performed once.

Raises: AmsdalRuntimeError: If the AMSDAL manager is already set up.

Returns: None

build method descriptor

build(
    source_models_path,
    source_transactions_path,
    source_static_files_path,
    source_fixtures_path,
    source_migrations_path,
)

Builds the necessary components for the Amsdal framework.

This method is used to build the necessary components for the Amsdal framework. It takes five parameters which are all of type Path. These parameters represent the paths to the directories where the corresponding components are located.

Args: source_models_path (Path): Path to the directory where the source models are located. source_transactions_path (Path): Path to the directory where the source transactions are located. source_static_files_path (Path): Path to the directory where the source static files are located. source_fixtures_path (Path): Path to the directory where the source fixtures are located. source_migrations_path (Path): Path to the directory where the source migrations are located.

Returns: None

The method performs the following build steps in order: - Builds the models from the source_models_path by calling the build_models method. - Builds the transactions from the source_transactions_path by calling the build_transactions method. - Builds the static files from the source_static_files_path by calling the build_static_files method. - Builds the fixtures from the source_fixtures_path by calling the build_fixtures method.

Note: This method is part of the AmsdalManager class which includes mixins for BuildMixin and ClassVersionsMixin. It is intended to be used in the Amsdal framework for managing and building components.

migrate method descriptor

migrate()

DEPRECATED: Check changes in the models and apply them to the database.

This method is deprecated and should not be used. It checks for changes in the models and applies them to the database. Use amsdal.migration.file_migration_generator.FileMigrationGenerator instead.

Raises: DeprecationWarning: Always raised to indicate that this method is deprecated.

Returns: None

authenticate method descriptor

authenticate()

Run AMSDAL license authentication process.

This method runs the AMSDAL license authentication process and sets the authentication status accordingly.

Returns: None

apply_fixtures method descriptor

apply_fixtures()

Loads and applies fixtures defined in your application.

This method loads the fixtures from the specified path and applies them to the AMSDAL framework. It uses the FixturesManager to manage the loading and application of the fixtures.

Returns: None

teardown method descriptor

teardown()

Clean up everything on the application exit.

This method performs a cleanup of all components managed by the AMSDAL framework when the application exits. It disconnects and invalidates connections, clears caches, and resets the setup status.

Raises: AmsdalRuntimeError: If the AMSDAL manager is not set up.

Returns: None