summaryrefslogtreecommitdiff
path: root/warlock
diff options
context:
space:
mode:
authorBrian Waldon <bcwaldon@gmail.com>2012-11-26 11:40:09 -0500
committerBrian Waldon <bcwaldon@gmail.com>2012-11-26 11:40:09 -0500
commitec39437bfd7a710e5ac5d4e4ca3236391c90998a (patch)
tree9995591edf72f3ec2e5a1526af75e17c9db16150 /warlock
parentd34e169d1eb97b6fa84acf39ec2722d9ce77eaba (diff)
downloadwarlock-ec39437bfd7a710e5ac5d4e4ca3236391c90998a.tar.gz
Allow delattr and del operations
Diffstat (limited to 'warlock')
-rw-r--r--warlock/core.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/warlock/core.py b/warlock/core.py
index da662ec..38cb854 100644
--- a/warlock/core.py
+++ b/warlock/core.py
@@ -76,7 +76,18 @@ def model_factory(schema):
raise InvalidOperation()
def __delitem__(self, key):
- raise InvalidOperation()
+ mutation = dict(self.items())
+ del mutation[key]
+ try:
+ self.validator(mutation)
+ except ValidationError:
+ msg = "Unable to delete attribute '%s'" % (key)
+ raise InvalidOperation(msg)
+
+ dict.__delitem__(self, key)
+
+ def __delattr__(self, key):
+ self.__delitem__(key)
# NOTE(termie): This is kind of the opposite of what copy usually does
def copy(self):