App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | List of all members
google.appengine.ext.db.ComputedProperty Class Reference
Inheritance diagram for google.appengine.ext.db.ComputedProperty:
google.appengine.ext.db.Property

Public Member Functions

def __init__
 
def __set__
 
def __get__
 
- Public Member Functions inherited from google.appengine.ext.db.Property
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

- Public Attributes inherited from google.appengine.ext.db.Property
 verbose_name
 
 name
 
 default
 
 required
 
 validator
 
 choices
 
 indexed
 
 creation_counter
 
 model_class
 
- Static Public Attributes inherited from google.appengine.ext.db.Property
int creation_counter = 0
 
 data_type = str
 

Detailed Description

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())

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

The documentation for this class was generated from the following file: