Purpose
This library is one part of a two part piece of code. It fulfills the server part to the flask-restless client. What it does is allow you to render your datamodel in a convenient JSON format. This JSON format is then read by the flask-restless-client, which in turn uses it to built itself, allowing for transparent access to your data model through HTTP.
Quickstart
Enabling this feature is as easy as registering an SQLAlchemy model in flask-restless. The only thing you need to do, is import the DataModel class from the library and use it to register your api.
import flask
import flask_restless
from flask_sqlalchemy import SQLAlchemy
from flask_restless_datamodel import DataModel
from my_models import Person, Computer, db
app = flask.Flask(__name__)
db = SQLAlchemy(app)
# Create a datamodel instance to register later
data_model = DataModel(manager)
manager = flask_restless.APIManager(app, flask_sqlalchemy_db=db)
manager.create_api(Person, methods=['GET'], include_columns=['name'])
manager.create_api(Computer, methods=['GET'], collection_name='compjutahs', exclude_columns=['name'])
manager.create_api(data_model, methods=['GET'])
# In case you want to expose the methods and properties as well
data_model.register_rpc_blueprint()
Which will expose an endpoint http://localhost:5000/flask-restless-datamodel which in turn will yield a result as followed
{
"Computer":{
"attributes":{
"id":"integer",
"owner_id":"integer",
"owner_name":"unicode",
"purchase_time":"datetime",
"vendor":"unicode"
},
"collection_name":"compjutahs",
"methods":{},
"pk_name":"id",
"relations":{
"owner":{
"backref":"computers",
"foreign_model":"Person",
"local_column":"owner_id",
"relation_type":"MANYTOONE"
},
"peers":{
"foreign_model":"Computer",
"is_proxy":true,
"relation_type":"MANYTOONE"
}
}
},
"Person":{
"attributes":{
"name":"unicode"
},
"collection_name":"person",
"methods":{},
"pk_name":"id",
"relations":{
}
}
}
This result will be used by the client code to build models on the fly.
Metadata
Release files for flask-restless-datamodel 0.3.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 | |
|---|---|---|---|---|
| flask-restless-datamodel-0.3.0.tar.gz | 16.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_restless_datamodel-0.3.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 29.2 kB
Release files / flask-restless-datamodel-0.3.0.tar.gz
| Download URL | flask-restless-datamodel-0.3.0.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0eda27674f880da69401f104c580694fb5dc129d2717644806728420582e9f77
|
|
BLAKE2b-256 checksum How to use checksums |
dd56f911e651e3f339a6683449b82e61a32eb2ef35aa75c6399ca77439a6a6d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / flask_restless_datamodel-0.3.0-py2.py3-none-any.whl
| Download URL | flask_restless_datamodel-0.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5999e1a14bed6fd1037d7afb10f1af0c5b0f9c086fc87e49f244e75eb03247ad
|
|
BLAKE2b-256 checksum How to use checksums |
d3420957e49b1a5d37cbe7d1d083b6595cdf2f8adfcb43fa0e1893560567add5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for flask-restless-datamodel 0.3.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.