class documentation

A descriptor that presents a read/write view of an object attribute.

Method __delete__ Undocumented
Method __get__ Undocumented
Method __init__ Construct a new :class:`.AssociationProxy`.
Method __repr__ Undocumented
Method __set__ Undocumented
Method for_class Return the internal state local to a specific mapped class.
Class Variable is_attribute True if this object is a Python :term:`descriptor`.
Instance Variable cascade_scalar_deletes Undocumented
Instance Variable creator Undocumented
Instance Variable getset_factory Undocumented
Instance Variable info Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`.
Instance Variable key Undocumented
Instance Variable proxy_bulk_set Undocumented
Instance Variable proxy_factory Undocumented
Instance Variable target_collection Undocumented
Instance Variable value_attr Undocumented
Method _as_instance Undocumented
Method _calc_owner Undocumented
Method _default_getset Undocumented
Instance Variable _attribute_options behavioral options for ORM-enabled Python attributes
Instance Variable _has_dataclass_arguments Undocumented

Inherited from InspectionAttrInfo:

Class Variable __slots__ Undocumented

Inherited from InspectionAttr (via InspectionAttrInfo):

Class Variable is_aliased_class True if this object is an instance of :class:`.AliasedClass`.
Class Variable is_bundle True if this object is an instance of :class:`.Bundle`.
Class Variable is_clause_element True if this object is an instance of :class:`_expression.ClauseElement`.
Class Variable is_instance True if this object is an instance of :class:`.InstanceState`.
Class Variable is_mapper True if this object is an instance of :class:`_orm.Mapper`.
Class Variable is_property True if this object is an instance of :class:`.MapperProperty`.
Class Variable is_selectable Return True if this object is an instance of :class:`_expression.Selectable`.
Class Variable _is_internal_proxy True if this object is an internal proxy object.
def __delete__(self, instance: object): (source)

Undocumented

@overload
def __get__(self, instance: Any, owner: Literal[None]) -> Self:
@overload
def __get__(self, instance: Literal[None], owner: Any) -> AssociationProxyInstance[_T]:
@overload
def __get__(self, instance: object, owner: Any) -> _T:
(source)

Undocumented

def __init__(self, target_collection: str, attr: str, *, creator: Optional[_CreatorProtocol] = None, getset_factory: Optional[_GetSetFactoryProtocol] = None, proxy_factory: Optional[_ProxyFactoryProtocol] = None, proxy_bulk_set: Optional[_ProxyBulkSetProtocol] = None, info: Optional[_InfoType] = None, cascade_scalar_deletes: bool = False, attribute_options: Optional[_AttributeOptions] = None): (source)

Construct a new :class:`.AssociationProxy`. The :class:`.AssociationProxy` object is typically constructed using the :func:`.association_proxy` constructor function. See the description of :func:`.association_proxy` for a description of all parameters.

def __repr__(self) -> str: (source)

Undocumented

def __set__(self, instance: object, values: _T): (source)

Undocumented

def for_class(self, class_: Type[Any], obj: Optional[object] = None) -> AssociationProxyInstance[_T]: (source)

Return the internal state local to a specific mapped class. E.g., given a class ``User``:: class User(Base): # ... keywords = association_proxy('kws', 'keyword') If we access this :class:`.AssociationProxy` from :attr:`_orm.Mapper.all_orm_descriptors`, and we want to view the target class for this proxy as mapped by ``User``:: inspect(User).all_orm_descriptors["keywords"].for_class(User).target_class This returns an instance of :class:`.AssociationProxyInstance` that is specific to the ``User`` class. The :class:`.AssociationProxy` object remains agnostic of its parent class. :param class\_: the class that we are returning state for. :param obj: optional, an instance of the class that is required if the attribute refers to a polymorphic target, e.g. where we have to look at the type of the actual destination object to get the complete path. .. versionadded:: 1.3 - :class:`.AssociationProxy` no longer stores any state specific to a particular parent class; the state is now stored in per-class :class:`.AssociationProxyInstance` objects.

is_attribute: bool = (source)

True if this object is a Python :term:`descriptor`. This can refer to one of many types. Usually a :class:`.QueryableAttribute` which handles attributes events on behalf of a :class:`.MapperProperty`. But can also be an extension type such as :class:`.AssociationProxy` or :class:`.hybrid_property`. The :attr:`.InspectionAttr.extension_type` will refer to a constant identifying the specific subtype. .. seealso:: :attr:`_orm.Mapper.all_orm_descriptors`

cascade_scalar_deletes = (source)

Undocumented

Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`. The dictionary is generated when first accessed. Alternatively, it can be specified as a constructor argument to the :func:`.column_property`, :func:`_orm.relationship`, or :func:`.composite` functions. .. versionchanged:: 1.0.0 :attr:`.MapperProperty.info` is also available on extension types via the :attr:`.InspectionAttrInfo.info` attribute, so that it can apply to a wider variety of ORM and extension constructs. .. seealso:: :attr:`.QueryableAttribute.info` :attr:`.SchemaItem.info`

def _as_instance(self, class_: Any, obj: Any) -> AssociationProxyInstance[_T]: (source)

Undocumented

def _calc_owner(self, target_cls: Any) -> Any: (source)

Undocumented

_attribute_options = (source)

behavioral options for ORM-enabled Python attributes .. versionadded:: 2.0