A very micro http framework.
Project description
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.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file yhttp_pony-5.0.1.tar.gz
.
File metadata
- Download URL: yhttp_pony-5.0.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3da30c3801bbcfb95cd8ac0d5dd334a273142d9a6db42c5a39c6d2ef2899d35 |
|
MD5 | cf10465efe3f75b43dce6f2294e88e3f |
|
BLAKE2b-256 | 8626421e85c61c6a56592864dd434a9efb603a583dafad7bf49c1e5025c37bc2 |
File details
Details for the file yhttp_pony-5.0.1-py3-none-any.whl
.
File metadata
- Download URL: yhttp_pony-5.0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b154202e21563fc5d7a9f98f51e65813e9e0abed3b8837ebc11520d597af20c3 |
|
MD5 | e41090b42aa18f3f71d8744b3d538fd6 |
|
BLAKE2b-256 | 38d7b994a1de3ba11a26c37bc8fd3456c582b18eb562b0c785b49e9a9fa08ca6 |