Make toDict "dereference" the 'name' property if it is present
This makes it possible to turn 'name' into a consistent alias that
can be used to represent an entity.
Patch by: Sverre Rabbelier
--- a/app/soc/models/base.py Wed Feb 04 22:52:33 2009 +0000
+++ b/app/soc/models/base.py Wed Feb 04 23:01:36 2009 +0000
@@ -53,13 +53,19 @@
"""
result = {}
+ props = self.properties()
- for key, value in self.properties().iteritems():
+ for key, value in props.iteritems():
# Skip everything but StringProperties
if not isinstance(value, db.StringProperty):
continue
result[key] = getattr(self, key)
+ if hasattr(self, 'name'):
+ name_prop = getattr(self, 'name')
+ if callable(name_prop):
+ result['name'] = name_prop()
+
return result
@classmethod