summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Turek <alex.turek@gmail.com>2016-06-25 10:44:52 -0700
committerBrian Waldon <brian@waldon.cc>2016-06-25 10:48:53 -0700
commit9d89de02df78a5315ec9e75145eb4a6578c05598 (patch)
tree9a5cc27dd96b8b29b9ae8878e751350fee33b38c
parent59c79b8c21ffdc7f1530f624c616bf6a842bc429 (diff)
downloadwarlock-9d89de02df78a5315ec9e75145eb4a6578c05598.tar.gz
Implement copy magic methods on Model
- Add Model.__copy__ - Add Model.__deepcopy__
-rw-r--r--warlock/model.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/warlock/model.py b/warlock/model.py
index e026bbb..666128c 100644
--- a/warlock/model.py
+++ b/warlock/model.py
@@ -25,6 +25,7 @@ from . import exceptions
class Model(dict):
+
def __init__(self, *args, **kwargs):
# we overload setattr so set this manually
d = dict(*args, **kwargs)
@@ -91,6 +92,12 @@ class Model(dict):
def copy(self):
return copy.deepcopy(dict(self))
+ def __copy__(self):
+ return self.copy()
+
+ def __deepcopy__(self, memo):
+ return copy.deepcopy(dict(self), memo)
+
def update(self, other):
mutation = dict(self.items())
mutation.update(other)