GqlQuery & JSON Question

17 views
Skip to first unread message

Elias

unread,
Nov 21, 2009, 7:49:16 AM11/21/09
to Google App Engine
Hi,

for my JavaScript frontend I need to print the gqlquery data as JSON
strings.
For that purpose I used this class:
http://code.google.com/p/google-app-engine-samples/source/browse/trunk/geochat/json.py?r=55

which works really great!

But it prints out ALL the data every time. Most of the data I don't
even need in the frontend like updated_at and the whole user
information per element.

Is there any possibility to reduce the data the GqlQuery loads?


Regards

Elias

Devraj Mukherjee

unread,
Nov 23, 2009, 8:19:41 PM11/23/09
to google-a...@googlegroups.com
Hi Elias,

As we develop our AppEngine apps, we are abstracting some of the code
that we are using to work with JSON. This might help. We are still
work from the JSON loads

Your model classes will need to subclass JSONSerializableModel

from django.utils import simplejson

class JSONSerializableModel(db.Model):

def from_json(self):
pass

def to_json(self):

jsonify_props = { }
for property_name, property_type in self.properties().iteritems():
jsonify_props[property_name] = getattr(self, property_name)

return simplejson.dumps(jsonify_props)
> --
>
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=.
>
>
>



--
"The secret impresses no-one, the trick you use it for is everything"
- Alfred Borden (The Prestiege)
Reply all
Reply to author
Forward
0 new messages