python only evaluates default function param values once, so mutable types will alway...
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 26 Jul 2007 20:30:16 +0000 (20:30 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 26 Jul 2007 20:30:16 +0000 (20:30 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1059 9efc2488-bf62-4759-914b-345cdb29e865

src/python/osrf/net_obj.py

index 8ae3b9b..1b65fbb 100644 (file)
@@ -70,21 +70,24 @@ def __makeSetField(cls):
     setattr(cls, 'setField', set)
         
 
-def __osrfNetworkObjectInit(self, data={}):
+def __osrfNetworkObjectInit(self, data=None):
     ''' __init__ method for osrNetworkObjects.
         If this is an array, we pull data out of the data array
         (if there is any) and translate that into a hash internally
         '''
     self.__data = data
-    if isinstance(data, list) and len(data) > 0:
-        reg = self.getRegistry()
-        if reg.wireProtocol == 'array':
-            self.__data = {}
-            for i in range(len(reg.keys)):
-                try:
-                    self.__data[reg.keys[i]] = data[i]
-                except:
-                    self.__data[reg.keys[i]] = None
+    if not data: self.__data = {}
+
+    if isinstance(data, list):
+        self.__data = {}
+        if len(data) > 0:
+            reg = self.getRegistry()
+            if reg.wireProtocol == 'array':
+                for i in range(len(reg.keys)):
+                    try:
+                        self.__data[reg.keys[i]] = data[i]
+                    except:
+                        self.__data[reg.keys[i]] = None
 
 
 def osrfNetworkRegisterHint(hint, keys, type='hash'):