Restler is an object Serialization library for the web. It supports translating objects to JSON or XML. Currently, it is targeted at Google App Engine with python 2.7.
Installation
Install Restler from PyPi using easy_install or pip; or download the package and run:
python setup.py install
(Running setup.py requires setuptools.)
For use on Google App Engine, you will need to install the code in the restler directory somewhere in your path.
Running Tests
To run restler’s tests:
pip install -r requirements.txt -t lib python -m unittest discover
Running tests requires python 2.7 the Google App Engine SDK or Google Cloud SDK
Usage
A db.Model or ndb.Model instance can be serialized with the default settings using to_json or to_xml.
>>> jean = Person(first_name="Jeanne", last_name="d'Arc", ssn="N/A")
>>> to_json(jean)
'{"first_name": "Jeanne", "last_name": "d\'Arc", "ssn": "N/A"}'
To include only certain fields, use a ModelStrategy. When using a ModelStrategy, you will need to use a restler model decorator.
>>> @ae_db_serializer >>> class User(db.Model) >>> ...
Now setup the ModelStrategy
>>> person_strategy = ModelStrategy(Person).include("first_name", "last_name")
>>> to_json(jean, person_strategy)
'{"first_name": "Jeanne", "last_name": "d'Arc"}'
Or, to exclude specified fields:
>>> person_strategy = ModelStrategy(Person, include_all_fields=True).exclude("ssn")
>>> to_json(jean, person_strategy)
'{"first_name": "Jeanne", "last_name": "d'Arc"}'
For more details on customizing serialization, see the documentation.
TODO
https://bitbucket.org/curtis/restler/issues?status=new&status=open
Metadata
Release files for restler-serialization 0.4.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 | |
|---|---|---|---|
| restler-serialization-0.4.1.tar.gz | 13.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| restler_serialization-0.4.1-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 44.6 kB
Release files / restler-serialization-0.4.1.tar.gz
| Download URL | restler-serialization-0.4.1.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1027198dd3f25596d058995e807cb2fc34182664b9b81ecfee545493f1ee93ce
|
|
BLAKE2b-256 checksum How to use checksums |
8daf1886484d3bd1fc76b6a5e758322207b5a224e798db74b2976e25a8e7d6e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / restler_serialization-0.4.1-py2.7.egg
| Download URL | restler_serialization-0.4.1-py2.7.egg |
|---|---|
| Size | 30.9 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
2e12ec30850988fedbcdf62735b249c15048c6274fc06e59ab7c7855f903017b
|
|
BLAKE2b-256 checksum How to use checksums |
4bf5dfd0361a61907633934916e4e1f62ae2524f225bc49e1f5c33ee53674bc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |