diff options
author | Brian Waldon <bcwaldon@gmail.com> | 2012-07-27 11:28:01 -0700 |
---|---|---|
committer | Brian Waldon <bcwaldon@gmail.com> | 2012-07-27 11:29:52 -0700 |
commit | 2c24556370b82dac6f97d316ec75931a74987b86 (patch) | |
tree | c1ae90e896e476e561102a52ad66901fd26b835a /warlock | |
parent | d93ca7833f4907939507bc99648de4d4d6eb0616 (diff) | |
download | warlock-2c24556370b82dac6f97d316ec75931a74987b86.tar.gz |
Enable dict-style access to models
Allow get and set of model attributes using dict-like
syntax (i.e. model['attribute'] = 'value').
Bump version to 0.2.0
Diffstat (limited to 'warlock')
-rw-r--r-- | warlock/core.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/warlock/core.py b/warlock/core.py index ee1d622..4b96345 100644 --- a/warlock/core.py +++ b/warlock/core.py @@ -53,6 +53,12 @@ def model_factory(schema): raise InvalidOperation() self.__dict__['raw'] = mutation + def __getitem__(self, key): + return self.__getattr__(key) + + def __setitem__(self, key, value): + return self.__setattr__(key, value) + def iteritems(self): return copy.deepcopy(self.__dict__['raw']).iteritems() |