dougrain-forms
A generator for hypermedia forms, following an unofficial draft by Mike Kelly. The format is roughly based on this Gist by Mike Kelly.
Installation
pip install dougrain-forms
Usage
Example:
from dougrain_forms import FormsMixin
class FormsDocument(Document, FormsMixin):
pass
doc = FormsDocument.empty()
doc.add_link('self', '/foo')
doc.set_form(
'attack',
'/attacks',
headers={
'Content-Type': 'application/json'
},
method='POST',
schema=ATTACK_SCHEMA
)
print(doc.as_object())
Output:
{
"_forms": {
"attack": {
"headers": {
"Content-Type": "application/json"
},
"href": "/attacks",
"method": "POST",
"schema": {
"required": [
"name",
"damage"
],
"type": "object",
"properties": {
"name": {
"type": "string"
},
"damage": {
"minimum": 0,
"type": "integer",
"description": "How much does it hurt?"
}
},
"title": "Damage Schema"
}
}
},
"_links": {
"self": {
"href": "/foo"
}
}
}
API
By mixing in FormMixin into your document, you get three new methods:
set_form(self, rel, target, **kwargs)
delete_form(self, rel)
form(self, href, **kwargs)
Until real docs have been written, take a look at the source.
Metadata
Release files for dougrain-forms 0.2.0
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 |
|---|---|---|---|---|
| dougrain-forms-0.2.0.tar.gz | 5.5 kB | Without provenance | Details for dougrain-forms-0.2.0.tar.gz |
Release files / dougrain-forms-0.2.0.tar.gz
| Download URL | dougrain-forms-0.2.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13a14cd807d7794c9465a267a36ef4c238167ebdd6ff8a01f4df4d0f91bd660f
|
|
BLAKE2b-256 checksum How to use checksums |
d54f055e1ca3975adb141e9ccbbdef413676983df3a7c7d002d65d0b1b7911f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dougrain-forms 0.2.0
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.