API
Commands
CLI
Loaders
Patchers
- class app_enabler.patcher.DisableExecute[source]
Patch the
manage.pymodule to remove the execute_from_command_line execution.
- app_enabler.patcher.monkeypatch_manage(manage_file: str) CodeType[source]
Patch
manage.pyto be executable without actually running any command.By using ast we remove the
execute_from_command_linecall and add an unconditional call to the main function.- Parameters:
manage_file (str) – path to manage.py file
- Returns:
patched manage.py code
- app_enabler.patcher.setup_django()[source]
Initialize the django environment by leveraging
manage.py.This works by using
manage.pyto set theDJANGO_SETTINGS_MODULEenvironment variable fordjango.setup()to work as it’s unknown at runtime.This should be safer than reading the
manage.pylooking for the written variable as it rely on Django runtime behavior.Manage.py is monkeypatched in memory to remove the call “execute_from_command_line” and executed from memory.
- app_enabler.patcher.update_setting(project_setting: str, config: Dict[str, Any])[source]
Patch the settings module to include addon settings.
Original file is overwritten. As file is patched using AST, original comments and file structure is lost.