yhttp-pony
Pony ORM extension for yhttp.
Install
sudo apt`install python3-dev libpq-dev postgresql # Postgresql
pip install yhttp-pony
Usage
This is how to use the extension.
from yhttp import Appliation, json
from yhttp.ext import pony as ponyext
from pony.orm import db_session as dbsession, PrimaryKey, Required
app = Application()
app.settings.merge('''
db:
url: postgres://postgres:postgres@localhost/foo
''')
db = ponyext.install(app)
class Foo(db.Entity):
id = PrimaryKey(int, auto=True)
title = Required(str)
@app.route()
@json
@dbsession
def get(req):
return {f.id:f.title for f in Foo.select()}
app.ready()
Command line interface
There is some command line interfaces which will be automatically added to
your application when you call dbmanager.install(app, ...) and
ponyext.install(app, ...).
myapp db create
myapp db objects create
myapp db drop
Extending db sub-command
import easycli
from yhttp.ext import dbmanager, ponyext
from mypackage import app # yhttp application
class InsertMockupCommand(easycli.SubCommand):
__command__ = 'insert-mockup'
def __call__(self, args):
ponyext.initialize(app.db, app.settings.db)
# Insert mockup data
ponyext.deinitialize(app.db)
class VerifyObjectsCommand(easycli.SubCommand):
__command__ = 'verify'
__aliases__ = ['v']
def __call__(self, args):
ponyext.initialize(app.db, app.settings.db)
# Verify database objects
ponyext.deinitialize(app.db)
...
dbmanager.install(app, cliarguments=[InsertMockupCommand])
db = ponyext.install(app, cliarguments=[VerifyObjectsCommand])
Use it as:
myapp db create
myapp db insert-mockup
myapp db objects create
myapp db objects verify
myapp db drop
Contribution
Dependencies
Install postgresql brefore use of this project.
apt install postgresql
Prepare
Create and grant the postgresql role with createdb permission to
authenticate the current unix user within postgresql using the peer
authentication.
echo "CREATE USER ${USER} WITH CREATEDB" | sudo -u postgres psql
# Or
echo "ALTER USER ${USER} CREATEDB" | sudo -u postgres psql
Virtualenv
Create virtual environment:
make venv
Delete virtual environment:
make venv-delete
Activate the virtual environment:
source ./activate.sh
Install (editable mode)
Install this project as editable mode and all other development dependencies:
make env
Tests
Execute all tests:
make test
Execute specific test(s) using wildcard:
make test F=tests/test_db*
make test F=tests/test_form.py::test_querystringform
refer to pytest documentation for more info about invoking tests.
Execute tests and report coverage result:
make cover
make cover F=tests/test_static.py
make cover-html
Lint
make lint
Distribution
Execute these commands to create Python's standard distribution packages
at dist directory:
make sdist
make wheel
Or
make dist
to create both sdidst and wheel packages.
Clean build directory
Execute:
make clean
to clean-up previous dist/* and build/* directories.
PyPI
WARNING: Do not do this if you'r not responsible as author and or maintainer of this project.
Execute
make clean
make pypi
to upload sdists and wheel packages on PyPI.
Metadata
Release files for yhttp-pony 5.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| yhttp_pony-5.0.1.tar.gz | 7.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yhttp_pony-5.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.4 kB
Release files / yhttp_pony-5.0.1.tar.gz
| Download URL | yhttp_pony-5.0.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3da30c3801bbcfb95cd8ac0d5dd334a273142d9a6db42c5a39c6d2ef2899d35
|
|
BLAKE2b-256 checksum How to use checksums |
8626421e85c61c6a56592864dd434a9efb603a583dafad7bf49c1e5025c37bc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / yhttp_pony-5.0.1-py3-none-any.whl
| Download URL | yhttp_pony-5.0.1-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b154202e21563fc5d7a9f98f51e65813e9e0abed3b8837ebc11520d597af20c3
|
|
BLAKE2b-256 checksum How to use checksums |
38d7b994a1de3ba11a26c37bc8fd3456c582b18eb562b0c785b49e9a9fa08ca6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for yhttp-pony 5.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.