RETIRED, further work has moved to Debian project infrastructure
Go to file
Brian Waldon c9775d94cf Bump version to 0.8.2 2013-03-25 09:44:58 -07:00
test Add license headers to source files 2013-01-31 07:16:37 -08:00
warlock Add license headers to source files 2013-01-31 07:16:37 -08: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 Fixing requirements 2012-06-02 12:42:26 -07:00
README.md Update README with JSON Patch example 2013-01-31 07:45:33 -08:00
requirements.txt Allow jsonschema<2.0 too. 2013-02-25 19:32:00 +01:00
setup.py Bump version to 0.8.2 2013-03-25 09:44:58 -07:00
tox.ini Fixing requirements 2012-06-02 12:42:26 -07: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"}]'