class documentation

class AssociationProxyInstance(object):

Known subclasses: sqlalchemy.ext.associationproxy.ColumnAssociationProxyInstance, sqlalchemy.ext.associationproxy.ObjectAssociationProxyInstance, sqlalchemy.ext.associationproxy.AmbiguousAssociationProxyInstance

View In Hierarchy

A per-class object that serves class- and object-specific results.

This is used by .AssociationProxy when it is invoked in terms of a specific class or instance of a class, i.e. when it is used as a regular Python descriptor.

When referring to the .AssociationProxy as a normal Python descriptor, the .AssociationProxyInstance is the object that actually serves the information. Under normal circumstances, its presence is transparent:

>>> User.keywords.scalar
False

In the special case that the .AssociationProxy object is being accessed directly, in order to get an explicit handle to the .AssociationProxyInstance, use the .AssociationProxy.for_class method:

proxy_state = inspect(User).all_orm_descriptors["keywords"].for_class(User)

# view if proxy object is scalar or not
>>> proxy_state.scalar
False
New in version 1.3.
Class Method for​_proxy Undocumented
Method any Produce a proxied 'any' expression using EXISTS.
Method delete Undocumented
Method get Undocumented
Method has Produce a proxied 'has' expression using EXISTS.
Method set Undocumented
Instance Variable target​_class The intermediary class handled by this .AssociationProxyInstance.
Class Method ​_cls​_unwrap​_target​_assoc​_proxy Undocumented
Class Method ​_construct​_for​_assoc Undocumented
Method __clause​_element__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method ​_criterion​_exists Undocumented
Method ​_default​_getset Undocumented
Method ​_get​_property Undocumented
Method ​_inflate Undocumented
Method ​_initialize​_scalar​_accessors Undocumented
Method ​_new Undocumented
Method ​_set Undocumented
Instance Variable ​_scalar​_get Undocumented
Instance Variable ​_scalar​_set Undocumented
Instance Variable collection​_class Undocumented
Instance Variable key Undocumented
Instance Variable owning​_class Undocumented
Instance Variable parent Undocumented
Instance Variable target​_collection Undocumented
Instance Variable value​_attr Undocumented
Property ​_comparator Undocumented
Property ​_target​_is​_object Undocumented
Property ​_unwrap​_target​_assoc​_proxy Undocumented
Property ​_value​_is​_scalar Undocumented
Property attr Return a tuple of (local_attr, remote_attr).
Property info Undocumented
Property local​_attr The 'local' class attribute referenced by this .AssociationProxyInstance.
Property remote​_attr The 'remote' class attribute referenced by this .AssociationProxyInstance.
Property scalar Return True if this .AssociationProxyInstance proxies a scalar relationship on the local side.
@classmethod
def for_proxy(cls, parent, owning_class, parent_instance):

Undocumented

def any(self, criterion=None, **kwargs):

Produce a proxied 'any' expression using EXISTS.

This expression will be a composed product using the .RelationshipProperty.Comparator.any and/or .RelationshipProperty.Comparator.has operators of the underlying proxied attributes.

def delete(self, obj):

Undocumented

def get(self, obj):
def has(self, criterion=None, **kwargs):

Produce a proxied 'has' expression using EXISTS.

This expression will be a composed product using the .RelationshipProperty.Comparator.any and/or .RelationshipProperty.Comparator.has operators of the underlying proxied attributes.

def set(self, obj, values):

Undocumented

target_class =

The intermediary class handled by this .AssociationProxyInstance.

Intercepted append/set/assignment events will result in the generation of new instances of this class.

@classmethod
def _cls_unwrap_target_assoc_proxy(cls, target_class, value_attr):

Undocumented

@classmethod
def _construct_for_assoc(cls, target_assoc, parent, owning_class, target_class, value_attr):

Undocumented

def __clause_element__(self):

Undocumented

def __init__(self, parent, owning_class, target_class, value_attr):

Undocumented

def __repr__(self):

Undocumented

def _criterion_exists(self, criterion=None, **kwargs):

Undocumented

def _default_getset(self, collection_class):

Undocumented

def _get_property(self):

Undocumented

def _inflate(self, proxy):

Undocumented

def _initialize_scalar_accessors(self):

Undocumented

def _new(self, lazy_collection):

Undocumented

def _set(self, proxy, values):

Undocumented

_scalar_get =

Undocumented

_scalar_set =

Undocumented

collection_class =

Undocumented

key =

Undocumented

owning_class =

Undocumented

parent =

Undocumented

target_collection =

Undocumented

value_attr =

Undocumented

@property
_comparator =

Undocumented

@util.memoized_property
_unwrap_target_assoc_proxy =

Undocumented

@util.memoized_property
_value_is_scalar =

Undocumented

@property
attr =

Return a tuple of (local_attr, remote_attr).

This attribute was originally intended to facilitate using the _query.Query.join method to join across the two relationships at once, however this makes use of a deprecated calling style.

To use _sql.select.join or _orm.Query.join with an association proxy, the current method is to make use of the .AssociationProxyInstance.local_attr and .AssociationProxyInstance.remote_attr attributes separately:

stmt = (
    select(Parent).
    join(Parent.proxied.local_attr).
    join(Parent.proxied.remote_attr)
)

A future release may seek to provide a more succinct join pattern for association proxy attributes.

See Also

.AssociationProxyInstance.local_attr

.AssociationProxyInstance.remote_attr

@property
info =

Undocumented

@property
local_attr =

The 'local' class attribute referenced by this .AssociationProxyInstance.

See Also

.AssociationProxyInstance.attr

.AssociationProxyInstance.remote_attr

@property
remote_attr =

The 'remote' class attribute referenced by this .AssociationProxyInstance.

See Also

.AssociationProxyInstance.attr

.AssociationProxyInstance.local_attr

Return True if this .AssociationProxyInstance proxies a scalar relationship on the local side.