RETIRED, further work has moved to Debian project infrastructure
Go to file
iccha.sethi 97d6f13fe2 Add description to exception messages
Add description to exception messages, so users know how they
violated the schema.
2013-09-06 13:59:26 -04:00
test Add python3 support 2013-07-23 07:10:27 -07: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 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 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 Add python3 support 2013-07-23 07:10:27 -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"}]'