turning gqlquery outcome set python dictionary
let's contend i have denote this
class foo(db.model):
id = db.stringproperty()
bar = db.stringproperty()
baz = db.stringproperty()
and i'm going gqlquery this
foos = db.gqlquery("select * foo")
i wish take law gqlquery spin arrange json twine i manipulate opposite languages.
here's i'm doing now
add slight foo category translates dictionary
def todict(self):
relapse {
'id': self.id,
'bar': self.bar,
'baz': self'baz
}loop by gqlquery law manually supplement any foo instance dictionary
foodict = {}
for foo foos:
foodict[foo.id] = foo.todict()
return simplejson.dumps(foodict)
my proceed above works nonetheless feels kind gross.
is there cleaner, some-more "pythonic" proceed hoop this?
the finish format doesn't have accurately i've finished above. only something translates simply json i understanding javascript/php/whatever.
Comments
Post a Comment