Pony-WTF
Pony-WTF is an integration library for Ponyorm and WTF-Forms.
Installation
pip install pony-wtf
Usage
# imports from pony-wtf
from pony_wtf import model_form
from pony_wtf.utils import get_attrs_dict
# declare database entities
class User(db.Entity):
id = PrimaryKey(int, auto=True)
email = Required(str, unique=True)
age = Optional(int)
form_cls = model_form(User, )
form = form_cls()
def get_form_values(entity, form_data):
""" Get form values and return them as dict """
d = {}
adict = get_attrs_dict(entity)
for k in adict:
if k in form_data:
d[k] = form_data.get(k)
return d
@app.route('/create_user', methods=['GET', 'POST'])
def create_user():
form_cls = model_form(User)
form = form_cls() # instaniatte the class
if request.method == 'POST' and form.validate_on_submit():
data = get_form_values(User, form.data)
with db_session:
User(**data)
flash("User Created", "success")
return redirect(url_for("index"))
return render_template('create_user.html', form=form)
You can render the form as you prefer in the jinjaHTML. Ex: {# Use Flask-WTF and Flask-Bootstrap #} {{ wtf.quick_form(form) }}
Requirements
pony pony_wtf Flask_WTF WTForms
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
[MIT]
Metadata
Release files for pony-wtf 0.0.1.post7
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 | Actions |
|---|---|---|---|---|
| pony_wtf-0.0.1.post7.tar.gz | 12.2 kB | Without provenance | Details for pony_wtf-0.0.1.post7.tar.gz |
Release files / pony_wtf-0.0.1.post7.tar.gz
| Download URL | pony_wtf-0.0.1.post7.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5937aa5ef81472a03850db196b04313953c717a69ad60fad8a9e21a4e1db558d
|
|
BLAKE2b-256 checksum How to use checksums |
d6b8a1e95cd1421d382227a5aa03451c3ab757da0f30aa89721c83211221b2bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for pony-wtf 0.0.1.post7
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.