Hi there.I get the following error only on production: BadRequestError: BLOB, ENITY_PROTO or TEXT properties must be in a raw_property fieldIt happens when I put() a instance of the Receipt class (extends ndb.Model)Below, I attach the model and the handler where the code breaks (only in production)class Receipt(RModel):ownerId = ndb.IntegerProperty()houseId = ndb.IntegerProperty()renterId = ndb.IntegerProperty()year = ndb.IntegerProperty()month_number = ndb.IntegerProperty()code = ndb.StringProperty()description = ndb.StringProperty()value = ndb.StringProperty()owner = ndb.ComputedProperty(lambda self: Owner.get_by_id(self.ownerId))house = ndb.ComputedProperty(lambda self: House.get_by_id(self.houseId))renter = ndb.ComputedProperty(lambda self: Renter.get_by_id(self.renterId))month = ndb.ComputedProperty(lambda self: month_number_to_string(self.month_number))
class RModel(ndb.Model):created = ndb.DateTimeProperty(auto_now_add = True)changed = ndb.DateTimeProperty(auto_now_add = True)creatorId = ndb.IntegerProperty()changerId = ndb.IntegerProperty()#def to_dict(self):# return ndb.to_dict(self, {'id':self.key().id()})
class DecimalProperty(ndb.StringProperty):
def _validate(self,value):
if not isinstance(value,(int,long,basestring,decimal.Decimal)):
raise ndb.BadValueError("Property %s must be a decimal, string, float or int." % self.name)
return decimal.Decimal(value).quantize(TWOPLACES)
def _to_base_type(self,value):
if value>=0:
return "P%010d" % (value*100)
else:
new_value = MAX_DECIMAL + (value*100)
return "N%010d" % new_value
def _from_base_type(self,value):
if value[0] == "P":
return (decimal.Decimal(value[1:])/100).quantize(TWOPLACES)
else:
tmp = decimal.Decimal(value[1:])
tmp = - (MAX_DECIMAL - tmp)
return (decimal.Decimal(tmp)/100).quantize(TWOPLACES)
class Accounting(ndb.Model):
expense = DecimalProperty(required=False,indexed=False,default=DEC_ZERO)
investment = DecimalProperty(required=False,indexed=False,default=DEC_ZERO)
def accountable_basic_compute_balance(accountable):
expense = accountable.commited.expense - accountable.invoiced.expense
investment = accountable.invoiced.investment - accountable.invoiced.investment
return Accounting(expense = expense, investment = investment)
class AccountableBasic(ndb.Model):
def __init__(self, *args, **kwargs):
# initialize structure
super(AccountableBasic, self).__init__(*args, **kwargs)
self.commited = Accounting()
self.invoiced = Accounting()
commited = ndb.StructuredProperty(Accounting, repeated = False, indexed=True)
invoiced = ndb.StructuredProperty(Accounting, repeated = False, indexed=True)
balance = ndb.ComputedProperty(accountable_basic_compute_balance, repeated = False, indexed=True)
class YearAccounting(AccountableBasic):
# id (key_name) = year
passBadRequestError: BLOB, ENITY_PROTO or TEXT properties must be in a raw_property field
| balance (entity:proto) | <binary> |
I don't think this has anything to do with the previous thread that had the same subject.