From 1839c221319e57448facea57ce22ad78cd229423 Mon Sep 17 00:00:00 2001 From: Dave Gaeddert Date: Fri, 5 Jul 2024 17:23:26 -0500 Subject: [PATCH] Rename BOLT to PLAIN --- plain-db/plain/db/__init__.py | 4 ++-- plain-db/plain/db/models/base.py | 6 +++--- plain-db/plain/db/models/query.py | 6 +++--- plain-db/plain/db/utils.py | 2 +- plain-dev/plain/dev/cli.py | 8 ++++---- plain-dev/plain/dev/config.py | 6 +++--- plain-dev/plain/dev/db/container.py | 2 +- plain-dev/plain/dev/pid.py | 2 +- plain-dev/plain/dev/requests.py | 2 +- plain-oauth/pyproject.toml | 2 +- plain-pytest/plain/pytest/cli.py | 6 +++--- plain-tailwind/plain/tailwind/core.py | 2 +- plain-worker/plain/worker/cli.py | 8 ++++---- plain/plain/assets/README.md | 2 +- plain/plain/cli/packages.py | 8 ++++---- plain/plain/internal/legacy/management/__init__.py | 4 ++-- plain/plain/internal/legacy/management/base.py | 4 ++-- plain/plain/logs/configure.py | 2 +- plain/plain/runtime/README.md | 2 +- plain/plain/runtime/__init__.py | 2 +- plain/plain/runtime/global_settings.py | 6 +++--- plain/plain/runtime/user_settings.py | 8 ++++---- plain/tests/conftest.py | 6 +++--- 23 files changed, 50 insertions(+), 50 deletions(-) diff --git a/plain-db/plain/db/__init__.py b/plain-db/plain/db/__init__.py index 696d0d443c..db95f43483 100644 --- a/plain-db/plain/db/__init__.py +++ b/plain-db/plain/db/__init__.py @@ -1,7 +1,7 @@ from plain import signals from plain.db.utils import ( - BOLT_VERSION_PICKLE_KEY, DEFAULT_DB_ALIAS, + PLAIN_VERSION_PICKLE_KEY, ConnectionHandler, ConnectionRouter, DatabaseError, @@ -32,7 +32,7 @@ "InterfaceError", "OperationalError", "DEFAULT_DB_ALIAS", - "BOLT_VERSION_PICKLE_KEY", + "PLAIN_VERSION_PICKLE_KEY", ] connections = ConnectionHandler() diff --git a/plain-db/plain/db/models/base.py b/plain-db/plain/db/models/base.py index cea405e7da..3caba4027d 100644 --- a/plain-db/plain/db/models/base.py +++ b/plain-db/plain/db/models/base.py @@ -7,7 +7,7 @@ import plain.runtime from plain import preflight from plain.db import ( - BOLT_VERSION_PICKLE_KEY, + PLAIN_VERSION_PICKLE_KEY, DatabaseError, connection, connections, @@ -555,7 +555,7 @@ def __hash__(self): def __reduce__(self): data = self.__getstate__() - data[BOLT_VERSION_PICKLE_KEY] = plain.runtime.__version__ + data[PLAIN_VERSION_PICKLE_KEY] = plain.runtime.__version__ class_id = self._meta.package_label, self._meta.object_name return model_unpickle, (class_id,), data @@ -577,7 +577,7 @@ def __getstate__(self): return state def __setstate__(self, state): - pickled_version = state.get(BOLT_VERSION_PICKLE_KEY) + pickled_version = state.get(PLAIN_VERSION_PICKLE_KEY) if pickled_version: if pickled_version != plain.runtime.__version__: warnings.warn( diff --git a/plain-db/plain/db/models/query.py b/plain-db/plain/db/models/query.py index 3d543ce264..aae8a79687 100644 --- a/plain-db/plain/db/models/query.py +++ b/plain-db/plain/db/models/query.py @@ -10,7 +10,7 @@ import plain.runtime from plain import exceptions from plain.db import ( - BOLT_VERSION_PICKLE_KEY, + PLAIN_VERSION_PICKLE_KEY, IntegrityError, NotSupportedError, connections, @@ -319,10 +319,10 @@ def __deepcopy__(self, memo): def __getstate__(self): # Force the cache to be fully populated. self._fetch_all() - return {**self.__dict__, BOLT_VERSION_PICKLE_KEY: plain.runtime.__version__} + return {**self.__dict__, PLAIN_VERSION_PICKLE_KEY: plain.runtime.__version__} def __setstate__(self, state): - pickled_version = state.get(BOLT_VERSION_PICKLE_KEY) + pickled_version = state.get(PLAIN_VERSION_PICKLE_KEY) if pickled_version: if pickled_version != plain.runtime.__version__: warnings.warn( diff --git a/plain-db/plain/db/utils.py b/plain-db/plain/db/utils.py index 8b90311bb9..50c46d1927 100644 --- a/plain-db/plain/db/utils.py +++ b/plain-db/plain/db/utils.py @@ -8,7 +8,7 @@ from plain.utils.module_loading import import_string DEFAULT_DB_ALIAS = "default" -BOLT_VERSION_PICKLE_KEY = "_django_version" +PLAIN_VERSION_PICKLE_KEY = "_django_version" class Error(Exception): diff --git a/plain-dev/plain/dev/cli.py b/plain-dev/plain/dev/cli.py index 21ca49d214..79f7b871f0 100644 --- a/plain-dev/plain/dev/cli.py +++ b/plain-dev/plain/dev/cli.py @@ -81,7 +81,7 @@ def run(self): pid.rm() def add_csrf_trusted_origins(self): - if "BOLT_CSRF_TRUSTED_ORIGINS" in os.environ: + if "PLAIN_CSRF_TRUSTED_ORIGINS" in os.environ: return csrf_trusted_origins = json.dumps( @@ -89,13 +89,13 @@ def add_csrf_trusted_origins(self): ) click.secho( - f"Automatically set BOLT_CSRF_TRUSTED_ORIGINS={click.style(csrf_trusted_origins, underline=True)}", + f"Automatically set PLAIN_CSRF_TRUSTED_ORIGINS={click.style(csrf_trusted_origins, underline=True)}", bold=True, ) # Set BASE_URL for plain and custom processes - self.plain_env["BOLT_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins - self.custom_process_env["BOLT_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins + self.plain_env["PLAIN_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins + self.custom_process_env["PLAIN_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins def run_preflight(self): if subprocess.run(["plain", "preflight"], env=self.plain_env).returncode: diff --git a/plain-dev/plain/dev/config.py b/plain-dev/plain/dev/config.py index 902fb45fa5..bd63bc1e50 100644 --- a/plain-dev/plain/dev/config.py +++ b/plain-dev/plain/dev/config.py @@ -13,8 +13,8 @@ def ready(self): plain_path = Path( importlib.util.find_spec("plain.runtime").origin ).parent.parent - if not settings.BOLT_TEMP_PATH.exists(): - settings.BOLT_TEMP_PATH.mkdir() - src_path = settings.BOLT_TEMP_PATH / "src" + if not settings.PLAIN_TEMP_PATH.exists(): + settings.PLAIN_TEMP_PATH.mkdir() + src_path = settings.PLAIN_TEMP_PATH / "src" if plain_path.exists() and not src_path.exists(): src_path.symlink_to(plain_path) diff --git a/plain-dev/plain/dev/db/container.py b/plain-dev/plain/dev/db/container.py index 333bd5ee94..a746b19cca 100644 --- a/plain-dev/plain/dev/db/container.py +++ b/plain-dev/plain/dev/db/container.py @@ -10,7 +10,7 @@ class DBContainer: def __init__(self): project_root = APP_PATH.parent - tmp_dir = settings.BOLT_TEMP_PATH + tmp_dir = settings.PLAIN_TEMP_PATH name = os.path.basename(project_root) + "-postgres-1" diff --git a/plain-dev/plain/dev/pid.py b/plain-dev/plain/dev/pid.py index 479f8452a7..429f682d2b 100644 --- a/plain-dev/plain/dev/pid.py +++ b/plain-dev/plain/dev/pid.py @@ -5,7 +5,7 @@ class Pid: def __init__(self): - self.pidfile = settings.BOLT_TEMP_PATH / "dev.pid" + self.pidfile = settings.PLAIN_TEMP_PATH / "dev.pid" def write(self): pid = os.getpid() diff --git a/plain-dev/plain/dev/requests.py b/plain-dev/plain/dev/requests.py index e0f12d6ca2..3afa831711 100644 --- a/plain-dev/plain/dev/requests.py +++ b/plain-dev/plain/dev/requests.py @@ -18,7 +18,7 @@ def __init__(self, *, request, response, exception=None): @staticmethod def storage_path(): - return str(settings.BOLT_TEMP_PATH / "requestlog") + return str(settings.PLAIN_TEMP_PATH / "requestlog") @classmethod def replay_request(cls, name): diff --git a/plain-oauth/pyproject.toml b/plain-oauth/pyproject.toml index 7a2fe74730..eb1d2fd44e 100644 --- a/plain-oauth/pyproject.toml +++ b/plain-oauth/pyproject.toml @@ -15,7 +15,7 @@ packages = [ [tool.pytest.ini_options] python_files = "tests.py test_*.py *_tests.py" -BOLT_SETTINGS_MODULE = "tests.settings" +PLAIN_SETTINGS_MODULE = "tests.settings" FAIL_INVALID_TEMPLATE_VARS = true [tool.poetry.dependencies] diff --git a/plain-pytest/plain/pytest/cli.py b/plain-pytest/plain/pytest/cli.py index c2b3c93623..124b4f0c7e 100644 --- a/plain-pytest/plain/pytest/cli.py +++ b/plain-pytest/plain/pytest/cli.py @@ -16,7 +16,7 @@ def cli(pytest_args): """Run tests with pytest""" - plain_tmp_dir = str(settings.BOLT_TEMP_PATH) + plain_tmp_dir = str(settings.PLAIN_TEMP_PATH) if not os.path.exists(os.path.join(plain_tmp_dir, ".gitignore")): os.makedirs(plain_tmp_dir, exist_ok=True) @@ -29,9 +29,9 @@ def cli(pytest_args): # pytest_args.append("-W") # pytest_args.append("error::DeprecationWarning") - os.environ.setdefault("BOLT_ENV", "test") + os.environ.setdefault("PLAIN_ENV", "test") - click.secho(f"Running pytest with BOLT_ENV={os.environ['BOLT_ENV']}", bold=True) + click.secho(f"Running pytest with PLAIN_ENV={os.environ['PLAIN_ENV']}", bold=True) result = subprocess.run( [ diff --git a/plain-tailwind/plain/tailwind/core.py b/plain-tailwind/plain/tailwind/core.py index 4665d3a1f4..cf05cf33de 100644 --- a/plain-tailwind/plain/tailwind/core.py +++ b/plain-tailwind/plain/tailwind/core.py @@ -21,7 +21,7 @@ class Tailwind: @property def target_directory(self) -> str: - return str(settings.BOLT_TEMP_PATH) + return str(settings.PLAIN_TEMP_PATH) @property def standalone_path(self) -> str: diff --git a/plain-worker/plain/worker/cli.py b/plain-worker/plain/worker/cli.py index 31f8b72d48..16a4ddb40a 100644 --- a/plain-worker/plain/worker/cli.py +++ b/plain-worker/plain/worker/cli.py @@ -34,28 +34,28 @@ def cli(): "max_processes", default=None, type=int, - envvar="BOLT_JOBS_MAX_PROCESSES", + envvar="PLAIN_JOBS_MAX_PROCESSES", ) @click.option( "--max-jobs-per-process", "max_jobs_per_process", default=None, type=int, - envvar="BOLT_JOBS_MAX_JOBS_PER_PROCESS", + envvar="PLAIN_JOBS_MAX_JOBS_PER_PROCESS", ) @click.option( "--max-pending-per-process", "max_pending_per_process", default=10, type=int, - envvar="BOLT_JOBS_MAX_PENDING_PER_PROCESS", + envvar="PLAIN_JOBS_MAX_PENDING_PER_PROCESS", ) @click.option( "--stats-every", "stats_every", default=60, type=int, - envvar="BOLT_JOBS_STATS_EVERY", + envvar="PLAIN_JOBS_STATS_EVERY", ) def run( queues, max_processes, max_jobs_per_process, max_pending_per_process, stats_every diff --git a/plain/plain/assets/README.md b/plain/plain/assets/README.md index 78ed042422..fc689c571f 100644 --- a/plain/plain/assets/README.md +++ b/plain/plain/assets/README.md @@ -48,7 +48,7 @@ ASSETS_FINDERS = [ # Absolute path to the directory assets files should be collected to. # Example: "/var/www/example.com/assets/" -ASSETS_ROOT = BOLT_TEMP_PATH / "assets_collected" +ASSETS_ROOT = PLAIN_TEMP_PATH / "assets_collected" # URL that handles the assets files served from ASSETS_ROOT. # Example: "http://example.com/assets/", "http://assets.example.com/" diff --git a/plain/plain/cli/packages.py b/plain/plain/cli/packages.py index 9a51575748..65b0792948 100644 --- a/plain/plain/cli/packages.py +++ b/plain/plain/cli/packages.py @@ -13,7 +13,7 @@ class InstalledPackagesGroup(click.Group): will be discovered automatically. """ - BOLT_APPS_PREFIX = "plain." + PLAIN_APPS_PREFIX = "plain." MODULE_NAME = "cli" def list_commands(self, ctx): @@ -26,8 +26,8 @@ def list_commands(self, ctx): cli_name = app.name - if cli_name.startswith(self.BOLT_APPS_PREFIX): - cli_name = cli_name[len(self.BOLT_APPS_PREFIX) :] + if cli_name.startswith(self.PLAIN_APPS_PREFIX): + cli_name = cli_name[len(self.PLAIN_APPS_PREFIX) :] packages_with_commands.append(cli_name) @@ -35,7 +35,7 @@ def list_commands(self, ctx): def get_command(self, ctx, name): # Try it as plain.x and just x (we don't know ahead of time which it is, but prefer plain.x) - for n in [self.BOLT_APPS_PREFIX + name, name]: + for n in [self.PLAIN_APPS_PREFIX + name, name]: try: cli = importlib.import_module(f"{n}.{self.MODULE_NAME}") except ModuleNotFoundError: diff --git a/plain/plain/internal/legacy/management/__init__.py b/plain/plain/internal/legacy/management/__init__.py index 2b023985d5..faed2ceb87 100644 --- a/plain/plain/internal/legacy/management/__init__.py +++ b/plain/plain/internal/legacy/management/__init__.py @@ -251,7 +251,7 @@ def fetch_command(self, subcommand): try: package_name = commands[subcommand] except KeyError: - if os.environ.get("BOLT_SETTINGS_MODULE"): + if os.environ.get("PLAIN_SETTINGS_MODULE"): # If `subcommand` is missing due to misconfigured settings, the # following line will retrigger an ImproperlyConfigured exception # (get_commands() swallows the original one) so the user is @@ -324,7 +324,7 @@ def autocomplete(self): (package_config.label, 0) for package_config in package_configs ) except ImportError: - # Fail silently if BOLT_SETTINGS_MODULE isn't set. The + # Fail silently if PLAIN_SETTINGS_MODULE isn't set. The # user will find out once they execute the command. pass parser = subcommand_cls.create_parser("", cwords[0]) diff --git a/plain/plain/internal/legacy/management/base.py b/plain/plain/internal/legacy/management/base.py index 95073b75a7..720809a9e9 100644 --- a/plain/plain/internal/legacy/management/base.py +++ b/plain/plain/internal/legacy/management/base.py @@ -88,7 +88,7 @@ def handle_default_options(options): user commands. """ if options.settings: - os.environ["BOLT_SETTINGS_MODULE"] = options.settings + os.environ["PLAIN_SETTINGS_MODULE"] = options.settings if options.pythonpath: sys.path.insert(0, options.pythonpath) @@ -319,7 +319,7 @@ def create_parser(self, prog_name, subcommand, **kwargs): help=( "The Python path to a settings module, e.g. " '"myproject.settings.main". If this isn\'t provided, the ' - "BOLT_SETTINGS_MODULE environment variable will be used." + "PLAIN_SETTINGS_MODULE environment variable will be used." ), ) self.add_base_argument( diff --git a/plain/plain/logs/configure.py b/plain/plain/logs/configure.py index 7b23b325d9..9c15a5e6e8 100644 --- a/plain/plain/logs/configure.py +++ b/plain/plain/logs/configure.py @@ -23,7 +23,7 @@ def configure_logging(logging_settings): "loggers": { "plain": { "handlers": ["console"], - "level": environ.get("BOLT_LOG_LEVEL", "INFO"), + "level": environ.get("PLAIN_LOG_LEVEL", "INFO"), }, "app": { "handlers": ["console"], diff --git a/plain/plain/runtime/README.md b/plain/plain/runtime/README.md index b7cd978c0f..e65c4609fa 100644 --- a/plain/plain/runtime/README.md +++ b/plain/plain/runtime/README.md @@ -32,7 +32,7 @@ The `.env` should then be in your `.gitignore`! It would seem like `.env.dev` would be a good idea, but there's a chicken-and-egg problem with that. -You would then have to prefix most (or all) of your local commands with `BOLT_ENV=dev` or otherwise configure your environment to do that for you. +You would then have to prefix most (or all) of your local commands with `PLAIN_ENV=dev` or otherwise configure your environment to do that for you. Generally speaking, a production `.env` shouldn't be committed in your repo anyway, so using `.env` for local development is ok. diff --git a/plain/plain/runtime/__init__.py b/plain/plain/runtime/__init__.py index 01d39847f1..c920ff5484 100644 --- a/plain/plain/runtime/__init__.py +++ b/plain/plain/runtime/__init__.py @@ -43,7 +43,7 @@ def setup(): sys.path.insert(0, APP_PATH.as_posix()) # Load .env files automatically before settings - if app_env := environ.get("BOLT_ENV", ""): + if app_env := environ.get("PLAIN_ENV", ""): load_dotenv(f".env.{app_env}") else: load_dotenv(".env") diff --git a/plain/plain/runtime/global_settings.py b/plain/plain/runtime/global_settings.py index 21ab1bc778..333b8a110c 100644 --- a/plain/plain/runtime/global_settings.py +++ b/plain/plain/runtime/global_settings.py @@ -1,6 +1,6 @@ """ Default Plain settings. Override these with settings in the module pointed to -by the BOLT_SETTINGS_MODULE environment variable. +by the PLAIN_SETTINGS_MODULE environment variable. """ from pathlib import Path @@ -12,7 +12,7 @@ DEBUG: bool = False -BOLT_TEMP_PATH: Path = default_app_path.parent / ".plain" +PLAIN_TEMP_PATH: Path = default_app_path.parent / ".plain" # Hosts/domain names that are valid for this site. # "*" matches anything, ".example.com" matches example.com and all subdomains @@ -162,7 +162,7 @@ # Absolute path to the directory assets files should be collected to. # Example: "/var/www/example.com/assets/" -ASSETS_ROOT = BOLT_TEMP_PATH / "assets_collected" +ASSETS_ROOT = PLAIN_TEMP_PATH / "assets_collected" # URL that handles the assets files served from ASSETS_ROOT. # Example: "http://example.com/assets/", "http://assets.example.com/" diff --git a/plain/plain/runtime/user_settings.py b/plain/plain/runtime/user_settings.py index 91a58ec120..2708a854a8 100644 --- a/plain/plain/runtime/user_settings.py +++ b/plain/plain/runtime/user_settings.py @@ -1,7 +1,7 @@ """ Settings and configuration for Plain. -Read values from the module specified by the BOLT_SETTINGS_MODULE environment +Read values from the module specified by the PLAIN_SETTINGS_MODULE environment variable, and then from plain.global_settings; see the global_settings.py for a list of all possible variables. """ @@ -18,8 +18,8 @@ from plain.packages import PackageConfig from plain.utils.functional import LazyObject, empty -ENVIRONMENT_VARIABLE = "BOLT_SETTINGS_MODULE" -ENV_SETTINGS_PREFIX = "BOLT_" +ENVIRONMENT_VARIABLE = "PLAIN_SETTINGS_MODULE" +ENV_SETTINGS_PREFIX = "PLAIN_" logger = logging.getLogger("plain.runtime") @@ -41,7 +41,7 @@ class LazySettings(LazyObject): """ A lazy proxy for either global Plain settings or a custom settings object. The user can manually configure settings prior to using them. Otherwise, - Plain uses the settings module pointed to by BOLT_SETTINGS_MODULE. + Plain uses the settings module pointed to by PLAIN_SETTINGS_MODULE. """ def _setup(self, name=None): diff --git a/plain/tests/conftest.py b/plain/tests/conftest.py index 848123bcb2..ba646c2a7c 100644 --- a/plain/tests/conftest.py +++ b/plain/tests/conftest.py @@ -2,6 +2,6 @@ def pytest_configure(config): - os.environ["BOLT_ENV_SETTING"] = "1" - os.environ["BOLT_ENV_OVERRIDDEN_SETTING"] = "env value" - os.environ["BOLT_UNDEFINED_SETTING"] = "not used" + os.environ["PLAIN_ENV_SETTING"] = "1" + os.environ["PLAIN_ENV_OVERRIDDEN_SETTING"] = "env value" + os.environ["PLAIN_UNDEFINED_SETTING"] = "not used"