![]() |
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 | make_value_from_datastore_index_value |
def | __property_config__ |
def | __get__ |
def | __set__ |
def | get_value_for_datastore |
def | validate |
![]() | |
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 |
Public Attributes | |
collection_name | |
reference_class | |
data_type | |
![]() | |
verbose_name | |
name | |
default | |
required | |
validator | |
choices | |
indexed | |
creation_counter | |
model_class | |
Additional Inherited Members | |
![]() | |
int | creation_counter = 0 |
data_type = str | |
A property that represents a many-to-one reference to another model. For example, a reference property in model A that refers to model B forms a many-to-one relationship from A to B: every instance of A refers to a single B instance, and every B instance can have many A instances refer to it.
def google.appengine.ext.db.ReferenceProperty.__init__ | ( | self, | |
reference_class = None , |
|||
verbose_name = None , |
|||
collection_name = None , |
|||
attrs | |||
) |
Construct ReferenceProperty. Args: reference_class: Which model class this property references. verbose_name: User friendly name of property. collection_name: If provided, alternate name of collection on reference_class to store back references. Use this to allow a Model to have multiple fields which refer to the same class.
def google.appengine.ext.db.ReferenceProperty.__get__ | ( | self, | |
model_instance, | |||
model_class | |||
) |
Get reference object. This method will fetch unresolved entities from the datastore if they are not already loaded. Returns: ReferenceProperty to Model object if property is set, else None. Raises: ReferencePropertyResolveError: if the referenced model does not exist.
def google.appengine.ext.db.ReferenceProperty.__property_config__ | ( | self, | |
model_class, | |||
property_name | |||
) |
Loads all of the references that point to this model. We need to do this to create the ReverseReferenceProperty properties for this model and create the <reference>_set attributes on the referenced model, e.g.: class Story(db.Model): title = db.StringProperty() class Comment(db.Model): story = db.ReferenceProperty(Story) story = Story.get(id) print [c for c in story.comment_set] In this example, the comment_set property was created based on the reference from Comment to Story (which is inherently one to many). Args: model_class: Model class which will have its reference properties initialized. property_name: Name of property being configured. Raises: DuplicatePropertyError if referenced class already has the provided collection name as a property.
def google.appengine.ext.db.ReferenceProperty.__set__ | ( | self, | |
model_instance, | |||
value | |||
) |
Set reference.
def google.appengine.ext.db.ReferenceProperty.get_value_for_datastore | ( | self, | |
model_instance | |||
) |
Get key of reference rather than reference itself.
def google.appengine.ext.db.ReferenceProperty.validate | ( | self, | |
value | |||
) |
Validate reference. Returns: A valid value. Raises: BadValueError for the following reasons: - Value is not saved. - Object not of correct model type for reference.