Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user-defined alternatives to piccolo_app and piccolo_conf files #896

Open
aabmets opened this issue Nov 1, 2023 · 1 comment
Open

Comments

@aabmets
Copy link

aabmets commented Nov 1, 2023

I don't like how piccolo requires its files to have piccolo_app.py and piccolo_conf.py names.
I want to have a single file piccolo.py with the following contents:

from piccolo.conf.apps import table_finder, AppConfig
from piccolo.engine.postgres import PostgresEngine
from piccolo.conf.apps import AppRegistry
from pathlib import Path

PICCOLO_DIR = Path(__file__).parent.resolve()
MIGRATIONS_DIR = (PICCOLO_DIR / "migrations").as_posix()

APP_CONFIG = AppConfig(...)
APP_REGISTRY = AppRegistry(...)
DB = PostgresEngine(...)

Currently, this works for an ASGI app, but piccolo CLI is broken, because the required
file names are hardcoded into the piccolo CLI source code.

Instead, the user should be able to provide an --option to piccolo CLI with a path to the
file which contains the class instances that piccolo requires.

Also, the APP_CONFIG, APP_REGISTRY and DB variable names should also be parametrized,
because forcing heavy opinions on developers is impolite.

@dantownsend
Copy link
Member

It's possible to change where Piccolo looks for the piccolo_conf.py file using an environment variable:

https://piccolo-orm.readthedocs.io/en/latest/piccolo/engines/index.html#piccolo-conf-environment-variable

Maybe we could also let the user specify it via the piccolo CLI command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants