views:

316

answers:

3

Hi.

I need to save in my model a list of objects from a certain class on the datastore.

Is there any simple way to archive this with ListProperty and custom property's without going into pickled/simplejson blob data?

I just want something like this:

class Test:
     pass

class model(db.Model):
     list = db.ListProperty(Test)

Looking at GAE documentation I can't really tell if this is impossible with the current version or not.

I was trying to avoid pickling because it's slow and has size limits.

A: 

You could save your Test objects in the datastore directly, by making a Test model/entity type. Otherwise you will have to serialize them somehow (using something like pickle or json)

Peter Recore
+1  A: 

You can only store a limited set of types directly in the datastore. To store your own types, you need to convert them into one of the accepted types in some manner - pickling is one common approach, as is serializing it as JSON.

The size limit isn't unique to pickling - 1MB is the largest Entity you can insert regardless of the fields and types.

Nick Johnson
A: 

You could have a list of keys or you could give 'Test' entities a parent that is a entity of your 'model' class

Drew LeSueur