Skip to content

Commit

Permalink
Rename BOLT to PLAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Jul 5, 2024
1 parent df523d0 commit 1839c22
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions plain-db/plain/db/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -32,7 +32,7 @@
"InterfaceError",
"OperationalError",
"DEFAULT_DB_ALIAS",
"BOLT_VERSION_PICKLE_KEY",
"PLAIN_VERSION_PICKLE_KEY",
]

connections = ConnectionHandler()
Expand Down
6 changes: 3 additions & 3 deletions plain-db/plain/db/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions plain-db/plain/db/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion plain-db/plain/db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions plain-dev/plain/dev/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ 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(
[f"http://localhost:{self.port}", f"http://127.0.0.1:{self.port}"]
)

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:
Expand Down
6 changes: 3 additions & 3 deletions plain-dev/plain/dev/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion plain-dev/plain/dev/db/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion plain-dev/plain/dev/pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion plain-dev/plain/dev/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion plain-oauth/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions plain-pytest/plain/pytest/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
[
Expand Down
2 changes: 1 addition & 1 deletion plain-tailwind/plain/tailwind/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions plain-worker/plain/worker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plain/plain/assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
8 changes: 4 additions & 4 deletions plain/plain/cli/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -26,16 +26,16 @@ 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)

return packages_with_commands

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:
Expand Down
4 changes: 2 additions & 2 deletions plain/plain/internal/legacy/management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions plain/plain/internal/legacy/management/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion plain/plain/logs/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion plain/plain/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion plain/plain/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions plain/plain/runtime/global_settings.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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/"
Expand Down
8 changes: 4 additions & 4 deletions plain/plain/runtime/user_settings.py
Original file line number Diff line number Diff line change
@@ -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.
"""
Expand All @@ -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")

Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions plain/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 1839c22

Please sign in to comment.