views:

34

answers:

1

I need to store a Django template object in a Model property.

My solution so far has been to pickle the object before assigning it to a BlobProperty :

entity.template_blob = pickle.dumps(template)
entity.put()

And then after a fetch from the datastore, I do :

template = pickle.loads(entity.template_blob)

Am I doing this wrong ? I couldn't find a property suited to the storage of any object.

+3  A: 

You've got it right. Pickling to a blob is the standard solution for this problem.

There isn't a built-in property that automatically handles the serialization / deserialization, but the PickleProperty in aetycoon will do this for you.

Drew Sears
Thanks for the pointer to aetycoon!
Franck