google app engine - Overide __setattr__ on GAE db.Model python 2.7 -


GAE db.Model can not store a list of tuples thus json.dumps me list string and json.loads Need to save as a string when I pull the list back from the unit. I want it to automatically go Here's my attempt:

  class instance (Dibikmodel): someAttr = db.StringListProperty () A = db.StringProperty () B = db.StringProperty () C = db.StringProperty () Dif Sitetrat __ __ (self, name, value): #convert json the name string of storage ( "a", "B", "C"): value = json.dumps ( value) #call set the default method return super ( "A", "B", "C") name: (= quotes, self) .__ setattr __ (name, value) def __getattribute __ (self, name): # convert To retrieve the string for json: val = Super (quotes, self) .__ getattribute __ (name) returns Jsonkloads (Val) Other: # default behavior back returns Super (quotes, self) .__ getattribute __ (name)   

when I A. I try to set, B, C attributes of what I get:

  Badwaluar error: property C should be a string or Unicode instance, no list   

If you do not have to store a large JSON, then I Suggest that you check Andibi. Jasonproperty is built in:

An interesting post also appeared in the App Engine Google Group which talks about large JSON storage in a more efficient way:

Comments