lback.commands package

This file serves as the initialization point for the ‘lback_framework/lback/commands’ package. It is designed to expose the core components necessary for executing various command-line utilities and management tasks within the Lback web framework. This package centralizes the definition and management of administrative and development-related commands, allowing developers to interact with the framework from the terminal.

Key Components Exposed by this Package:

  1. AdminCommands (from .admin): A collection of command-line utilities specifically designed for administrative tasks. These commands typically facilitate the management of the Lback admin interface, such as creating superusers, managing admin configurations, or performing other admin-specific operations from the terminal.

  2. AppCommands (from .app): A set of command-line utilities related to managing individual applications or modules within the Lback project. These commands might include functionalities for creating new app templates, managing app-specific configurations, or performing operations relevant to the lifecycle of an application.

  3. setup_database_and_defaults (from .db_seed): A function or utility responsible for seeding the database with initial data or default configurations. This command is crucial for setting up a fresh development environment or for populating a database with essential data required for the application to function correctly (e.g., default user roles, initial settings).

  4. MigrationCommands (from .migration): A collection of command-line utilities for managing database schema migrations. These commands typically integrate with a migration tool (like Alembic) to create new migration scripts, apply pending migrations to the database, or revert previous migrations, ensuring database schema changes are managed in a version-controlled manner.

  5. ProjectCommands (from .project): A set of command-line utilities related to managing the overall Lback project. These commands might include functionalities for initializing a new Lback project, setting up project-wide configurations, or performing operations relevant to the entire project’s structure and environment.

  6. RunnerCommands (from .runner): A collection of command-line utilities for running the Lback application or specific development servers. This typically includes commands to start the development server, run tests, or execute other processes necessary for developing and deploying the Lback application.

Submodules

lback.commands.admin module

class lback.commands.admin.AdminCommands[source][source]

Bases: object

Command-line utilities for administrative tasks, interacting with the database using the new system.

activate_user()[source][source]

Activates a user via command line.

create_superuser()[source][source]

Creates a new superuser via command line.

deactivate_user()[source][source]

Deactivates a user via command line.

init_db()[source][source]

Initializes the database schema by creating all tables. Note: This bypasses Alembic and is typically for initial setup or testing. For production, use Alembic migrations (manage.py migrate).

list_users()[source][source]

Lists all registered users via command line.

reset_password()[source][source]

Resets a user’s password via command line.

lback.commands.app module

class lback.commands.app.AppCommands(name)[source][source]

Bases: object

startapp()[source][source]

Create a new app structure.

lback.commands.db_seed module

lback.commands.db_seed.setup_database_and_defaults(db_manager_instance)[source][source]

Initializes the database schema and populates it with default groups and permissions. This should be called as part of a dedicated ‘seed_db’ command.

lback.commands.migration module

class lback.commands.migration.MigrationCommands(config=None)[source][source]

Bases: object

Provides command-line interface commands for managing database migrations using Alembic. Wraps Alembic subprocess calls and integrates SignalDispatcher to emit events.

__init__(config=None)[source][source]

Initializes MigrationCommands. Emits ‘migration_commands_initialized’ signal.

history()[source][source]

Shows the migration history using Alembic. Emits ‘migration_history_command’ signal.

makemigrations(message: str = 'auto')[source][source]

Creates a new migration script based on model changes using Alembic. Emits ‘migration_makemigrations_command’ signal.

migrate(version: str = 'head')[source][source]

Applies pending migrations to the database using Alembic. Emits ‘migration_migrate_command’ signal.

rollback(version: str = '-1')[source][source]

Rolls back migrations using Alembic. Emits ‘migration_rollback_command’ signal.

lback.commands.project module

class lback.commands.project.ProjectCommands(config, name)[source][source]

Bases: object

startproject()[source][source]

Create a new project structure.

lback.commands.runner module

class lback.commands.runner.RunnerCommands[source][source]

Bases: object

collectstatic(static_dirs=None, output_dir='staticfiles')[source][source]

Collect static files into a single directory.

runserver()[source][source]

Run the development server. Initializes core server components before running the server.

test(test_path=None)[source][source]

Run tests using pytest.