Saleor App Framework (Python) provides an easy way to install Your app into the Saleor Commerce.
Supported features:
- Installation
- Webhooks handling
- Exception handling
- Ignoring Webhooks triggered by your app
More on usage You can find in the official Documentation
To use saleor app framework simply install it by
Using poetry
poetry add git+https://github.com/saleor/saleor-app-framework-python.git@main
Using pip
pip install git+https://github.com/saleor/saleor-app-framework-python.git@main
The recommended way of building Saleor Python Applications using this framework, is to use project template from saleor-app-template. This template will save You a lot of time configuring Your project.
It is preconfigured to use:
- uvicorn [and gunicorn] - as HTTP server
- SQLAlchemy - as an ORM
- alembic - as a database migration tool with configured migration names, black and isort
- encode/databases - as an asyncio support for SQLAlchemy
- pytest - for unit tests
- poetry - as python package manager
With this template You will get:
- working Dockerfile and docker-compose.yaml
- working database with async support
- working configured tests
- working Saleor installation process
You can always develop Your own application from scratch, basing on the steps from Documentation or change any of the existing tools.
To execeute tests with tox just invoke tox
or tox -p
. The tox-poetry plugin will read pyproject.toml and handle the envs creation. In case of a change in the dependencies you can force a recreation of the envs with tox -r
.
One might also want to just run a specific testenv like: tox -e coverage
.
To reduce the noisy output use -q
like: tox -p -q
Here's an example gunicorn.conf.py
file:
from my_app.settings import LOGGING
workers = 2
keepalive = 30
worker_class = "uvicorn.workers.UvicornH11Worker"
bind = ["0.0.0.0:8080"]
accesslog = "-"
errorlog = "-"
loglevel = "info"
logconfig_dict = LOGGING
forwarded_allow_ips = "*"
It's a good starting point, keeps the log config in one place and includes the very important (forwarded_allow_ips
flag)[https://docs.gunicorn.org/en/stable/settings.html#forwarded-allow-ips] this flag needs to be understood when deploying your app - it's not always safe to set it to *
but in some setups it's the only option to allow FastAPI to generate proper urls with url_for
.