Hi,

I'm getting also this error trying to put() [to be exact, trying to do a 
get_or_insert] an entity with a computed property. My Model looks more or 
less like this (removed non-relevant code):

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
   pass

Everything works fine in the local dev server, when I try to perform a 
YearAccounting.get_or_insert in production, I get the following error:

BadRequestError: BLOB, ENITY_PROTO or TEXT properties must be in a raw_property 
field


I'm assuming that's related to the "balance" property in YearAccouting 
(subclass of AccountableBasic) , which in dev shows as follows in the 
datastore viewer:

balance (entity:proto)
<binary>

I had some problems previously in production trying to use a 
ComputedProperty that returned a DecimalProperty (basically, a "total" 
property: a ComputedProperty that returened a DecimalProperty): dev app 
server complained about it, so I've removed it, however it seemed to be 
happy with a ComputedProperty that returned a Accounting instance, but the 
production runtime doen't look so happy with it...

Any help will be welcome.

thanks in advance,
Jose


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/f0sh0Nm6hOcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to