[Opensrf-commits] r1059 - trunk/src/python/osrf
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jul 26 16:31:26 EDT 2007
Author: erickson
Date: 2007-07-26 16:30:16 -0400 (Thu, 26 Jul 2007)
New Revision: 1059
Modified:
trunk/src/python/osrf/net_obj.py
Log:
python only evaluates default function param values once, so mutable types will always be pointers to the original default val. change the default osrfNetworkObject init function to None and setting default manually
Modified: trunk/src/python/osrf/net_obj.py
===================================================================
--- trunk/src/python/osrf/net_obj.py 2007-07-24 01:48:09 UTC (rev 1058)
+++ trunk/src/python/osrf/net_obj.py 2007-07-26 20:30:16 UTC (rev 1059)
@@ -70,23 +70,26 @@
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'):
''' Registers a new network-serializable object class.
More information about the opensrf-commits
mailing list