Make it possible to retrieve all properties in toDict
authorSverre Rabbelier <srabbelier@gmail.com>
Thu, 02 Apr 2009 23:06:15 +0000
changeset 2059 4037b147ed10
parent 2058 773b13d86309
child 2060 45029d87be4a
Make it possible to retrieve all properties in toDict We used to retrieve only the properties that are specified in the self.properties() dictionary, instead, we now iterate over the key_fields and only use self.properties() if those are not specified. Patch by: Sverre Rabbelier
app/soc/models/base.py
--- a/app/soc/models/base.py	Thu Apr 02 23:05:56 2009 +0000
+++ b/app/soc/models/base.py	Thu Apr 02 23:06:15 2009 +0000
@@ -58,14 +58,14 @@
     """
 
     result = {}
-    props = self.properties()
 
     if not field_names:
+      props = self.properties()
       field_names = [k for k, v in props.iteritems() if isinstance(v, self.DICT_TYPES)]
 
-    for key, value in props.iteritems():
+    for key in field_names:
       # Skip everything that is not valid
-      if key not in field_names:
+      if not hasattr(self, key):
         continue
 
       result[key] = getattr(self, key)