Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to use ComputedProperty?

I need support for computed properties in App Engine. I downloaded the latest source release to try and implement them myself. Whilst going through code, I came across a property class that already seems to do exactly what I need.

class ComputedProperty(Property):
  """Property used for creating properties derived from other values.

  Certain attributes should never be set by users but automatically
  calculated at run-time from other values of the same entity.  These
  values are implemented as persistent properties because they provide
  useful search keys.

  ...
  """

The problem that it's undocumented; I can't find anything about ComputedProperty in the official docs.

So is ComputedProperty safe to use or is it buggy or/and subject to change?

like image 363
hwiechers Avatar asked Dec 28 '22 08:12

hwiechers


2 Answers

ComputedProperty seems to be a "port" (for lack of a better word) of a custom property class named DerivedProperty from Nick Johnson's blog.

Since Nick's blog entry shows how easy it can be to create a custom datastore Property class, I wouldn't worry much about ComputedProperty, as you can always replace it with a Property subclass of your own if need be.

like image 80
matt b Avatar answered Jan 13 '23 15:01

matt b


These have since been launched and documented, at least for the NDB API:

https://developers.google.com/appengine/docs/python/ndb/properties#computed

like image 41
John Mellor Avatar answered Jan 13 '23 16:01

John Mellor