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?
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.
These have since been launched and documented, at least for the NDB API:
https://developers.google.com/appengine/docs/python/ndb/properties#computed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With