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




  1. add slight foo category translates dictionary



    def todict(self):
    relapse {
    'id': self.id,
    'bar': self.bar,
    'baz': self'baz
    }

  2. 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

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?