diff wsgraph/model.py @ 9:0affca1f4dc0

start using deepcopy since lord knows we cant trust users
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Dec 2012 17:10:50 -0800
parents f1f7a505e0d0
children 81d68388ec97
line wrap: on
line diff
--- a/wsgraph/model.py	Mon Dec 10 17:08:02 2012 -0800
+++ b/wsgraph/model.py	Mon Dec 10 17:10:50 2012 -0800
@@ -1,4 +1,5 @@
 from abc import abstractmethod
+from copy import deepcopy
 from utils import iterable
 
 class GraphModel(object):
@@ -50,9 +51,10 @@
     def node(self, name, **values):
         if values:
             # setter
-            self._nodes[name] = values
+            self._nodes[name] = deepcopy(values)
         else:
             # getter
+            # TODO: deepcopy
             return self._nodes.get(name, None)
 
     def nodes(self):
@@ -61,9 +63,10 @@
     def edge(self, node1, node2, **values):
         if values:
             # setter
-            self._edges[(node1, node2)] = values
+            self._edges[(node1, node2)] = deepcopy(values)
         else:
             # getter
+            # TODO: deepcopy
             return self._edges.get((node1, node2), None)
 
     def edges(self):