RETIRED, further work has moved to Debian project infrastructure
Go to file
Brian Waldon 286c8dbcc3 Update version to 0.8.0 2013-01-21 09:27:49 -08:00
test Use jsonpatch to provide a JSON patch document 2012-11-26 12:23:12 -05:00
warlock Rename Model method validator to validate 2013-01-21 09:27:49 -08:00
.gitignore Break up core pieces into separate modules 2012-12-22 15:39:09 -08:00
HACKING Add Python 2.6 to tox runner 2012-06-02 12:12:19 -07:00
LICENSE Add Apache 2.0 LICENSE file 2012-06-01 14:02:49 -07:00
MANIFEST.in Fixing requirements 2012-06-02 12:42:26 -07:00
README.md Update README to reflect exception output 2012-11-19 14:08:18 -08:00
requirements.txt Relax jsonpatch dep to >=0.10,<=0.12 2013-01-21 09:27:49 -08:00
setup.py Update version to 0.8.0 2013-01-21 09:27:49 -08:00
tox.ini Fixing requirements 2012-06-02 12:42:26 -07:00

README.md

Warlock!

Wat

Build self-validating python objects using JSON schemas

How

  1. Build your schema

    schema = { 'name': 'Country', 'properties': { 'name': {'type': 'string'}, 'abbreviation': {'type': 'string'}, }, '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'