PickleProperty for db.Models

35 views
Skip to first unread message

Chris Tan

unread,
Jul 7, 2008, 7:20:42 PM7/7/08
to Google App Engine
Handy for storing dictionaries or other custom data types

Disadvantages:
- pickling takes time
- not indexable

Source:

from google.appengine.ext import db
import pickle

class PickleProperty(db.Property):
def get_value_for_datastore(self, model_instance):
value = getattr(model_instance, self.name, None)
return pickle.dumps(value)

def make_value_from_datastore(self, value):
return pickle.loads(value)

Reply all
Reply to author
Forward
0 new messages