![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | __set__ |
def | __get__ |
![]() | |
def | __init__ |
def | __property_config__ |
def | __get__ |
def | __set__ |
def | default_value |
def | validate |
def | empty |
def | get_value_for_datastore |
def | get_updated_value_for_datastore |
def | make_value_from_datastore_index_value |
def | make_value_from_datastore |
def | datastore_type |
Additional Inherited Members | |
![]() | |
verbose_name | |
name | |
default | |
required | |
validator | |
choices | |
indexed | |
creation_counter | |
model_class | |
![]() | |
int | creation_counter = 0 |
data_type = str | |
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. A computed property behaves the same as normal properties except that you may not set values on them. Attempting to do so raises db.DerivedPropertyError which db.Model knows to ignore during entity loading time. Whenever getattr is used for the property the value is recaclulated. This happens when the model calls get_value_for_datastore on the property. Example: import string class Person(Model): name = StringProperty(required=True) @db.ComputedProperty def lower_case_name(self): return self.name.lower() # Find all people regardless of case used in name. Person.gql('WHERE lower_case_name=:1' % name_to_search_for.lower())
def google.appengine.ext.db.ComputedProperty.__init__ | ( | self, | |
value_function, | |||
indexed = True |
|||
) |
Constructor. Args: value_function: Callable f(model_instance) -> value used to derive persistent property value for storage in datastore. indexed: Whether or not the attribute should be indexed.
def google.appengine.ext.db.ComputedProperty.__get__ | ( | self, | |
model_instance, | |||
model_class | |||
) |
Derive property value. Args: model_instance: Instance to derive property for in bound method case, else None. model_class: Model class associated with this property descriptor. Returns: Result of calling self.__value_funcion as provided by property constructor.
def google.appengine.ext.db.ComputedProperty.__set__ | ( | self, | |
args | |||
) |
Disallow setting this value. Raises: DerivedPropertyError when developer attempts to set attribute manually. Model knows to ignore this exception when getting from datastore.