RETIRED, further work has moved to Debian project infrastructure
Go to file
Wendell Smith 9dca65662e Use python 3.4 2015-06-22 16:55:05 -04:00
test Compare JSON strings as JSON instead of strings. 2015-04-13 10:13:54 +02:00
warlock Add description to exception messages 2013-09-06 13:59:26 -04:00
.gitignore Break up core pieces into separate modules 2012-12-22 15:39:09 -08:00
HACKING.txt Move HACKING to HACKING.txt 2013-01-31 07:17:02 -08:00
LICENSE.txt Add license headers to source files 2013-01-31 07:16:37 -08:00
MANIFEST.in LICENSE.txt was missing in the source tarball 2013-10-10 01:07:23 +02:00
README.md Update README with JSON Patch example 2013-01-31 07:45:33 -08:00
requirements.txt Add python3 support 2013-07-23 07:10:27 -07:00
setup.py Update version to 1.0.1 2013-06-28 09:47:26 -07:00
tox.ini Use python 3.4 2015-06-22 16:55:05 -04:00

README.md

Warlock

Build self-validating python objects using JSON schemas.

  1. Create your schema

    schema = { 'name': 'Country', 'properties': { 'name': {'type': 'string'}, 'abbreviation': {'type': 'string'}, 'population': {'type': 'integer'}, }, 'additionalProperties': False, }

  2. Create a model

    import warlock Country = warlock.model_factory(schema)

  3. Create an object using your model

    sweden = Country(name='Sweden', abbreviation='SE')

  4. Let the object validate itself

    sweden.name = 5 Traceback (most recent call last): File "", line 1, in File "warlock/core.py", line 53, in setattr raise InvalidOperation(msg) warlock.core.InvalidOperation: Unable to set 'name' to '5'

    sweden.overlord = 'Bears' Traceback (most recent call last): File "", line 1, in File "warlock/core.py", line 53, in setattr raise InvalidOperation(msg) warlock.core.InvalidOperation: Unable to set 'overlord' to 'Bears'

  5. Generate a JSON Patch document to track changes

    sweden.population=9453000 sweden.patch '[{"path": "/population", "value": 9453000, "op": "add"}]'