RETIRED, further work has moved to Debian project infrastructure
Go to file
Brian Waldon e8f0a5ade7 Bump version to 0.7.0 2012-11-26 12:26:25 -05:00
test Use jsonpatch to provide a JSON patch document 2012-11-26 12:23:12 -05:00
warlock Use jsonpatch to provide a JSON patch document 2012-11-26 12:23:12 -05:00
.gitignore Add basic test and implement minimal logic 2012-06-01 15:00:38 -07: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 Use jsonpatch to provide a JSON patch document 2012-11-26 12:23:12 -05:00
setup.py Bump version to 0.7.0 2012-11-26 12:26:25 -05: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'