Provides integrations of classic libs with Falcon web framework
Project description
Classic Falcon Integration
Предоставляет простую интеграцию веб-фреймворка Falcon, orjson и classic-error-handling.
Установка
pip install classic-falcon-integration
Quickstart
from falcon import App, Request, Response
from pydantic import BaseModel
import waitress
from classic.components import component
from classic.falcon_integration import register_all
from classic import db_tools
class Pet(BaseModel):
id: int
name: str
age: int
class FilterPets(BaseModel):
name__contains: list[str] | None = None
age__le: int | None = None
age__gt: int | None = None
id: int | None = None
class NewPet(BaseModel):
name: str
age: int
@component
class PetsResource:
db: db_tools.Engine
def on_get(self, request: Request, response: Response):
# Валидация по спецификации отключена по умолчанию,
# потому вызов валидации обязательно добавлять вручную.
# Валидацию лучше сего проводить через model_validate,
# так как далее данные все равно будут переданы в виде dict
FilterPets.model_validate(request.params)
# Здесь приведен пример работы с БД с classic-db-tools,
# но здесь может быть что угодно
with self.db:
response.media = self.db.queries.filter_pets(
**request.params
).return_as(
db_tools.ToCls(Pet, id='id'),
returns=Pet,
).many()
def on_post(self, request: Request, response: Response):
NewPet.model_validate(request.media)
with self.db:
response.media = self.db.queries.save_pet(
**request.media,
)
if __name__ == '__main__':
app = App()
app.add_route('/api/pets', PetsResource())
register_all(app)
waitress.serve(
app,
host='127.0.0.1',
port='8000',
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file classic_falcon_integration-2.0.1.tar.gz.
File metadata
- Download URL: classic_falcon_integration-2.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0306c65469258ba834c97d67fbdc0b3f0dda6c8c327980fe51dab9902c6f33fa
|
|
| MD5 |
78bd78fe35ff9bb42c064097dfa54312
|
|
| BLAKE2b-256 |
03d32f383c5fc7d0871a5253334d4ffd024218518a2290676614502a1cd368cc
|
Provenance
The following attestation bundles were made for classic_falcon_integration-2.0.1.tar.gz:
Publisher:
publish.yml on variasov/classic-falcon-integration
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
classic_falcon_integration-2.0.1.tar.gz -
Subject digest:
0306c65469258ba834c97d67fbdc0b3f0dda6c8c327980fe51dab9902c6f33fa - Sigstore transparency entry: 1304710715
- Sigstore integration time:
-
Permalink:
variasov/classic-falcon-integration@8db8dd08ac3498f138936426b64ca8349783ddb2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/variasov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8db8dd08ac3498f138936426b64ca8349783ddb2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file classic_falcon_integration-2.0.1-py3-none-any.whl.
File metadata
- Download URL: classic_falcon_integration-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eecb8482a5d3dd4c3fb8959d21434454212e028e26bac7216cae328eef30375f
|
|
| MD5 |
37659c207e9c50165bc002daf8c8595d
|
|
| BLAKE2b-256 |
7c8454a3b47e5bb828fea035c178d92cf740190dbfc02fd3c7903b18150bd33b
|
Provenance
The following attestation bundles were made for classic_falcon_integration-2.0.1-py3-none-any.whl:
Publisher:
publish.yml on variasov/classic-falcon-integration
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
classic_falcon_integration-2.0.1-py3-none-any.whl -
Subject digest:
eecb8482a5d3dd4c3fb8959d21434454212e028e26bac7216cae328eef30375f - Sigstore transparency entry: 1304710815
- Sigstore integration time:
-
Permalink:
variasov/classic-falcon-integration@8db8dd08ac3498f138936426b64ca8349783ddb2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/variasov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8db8dd08ac3498f138936426b64ca8349783ddb2 -
Trigger Event:
push
-
Statement type: