class documentation

class SynonymProperty(DescriptorProperty):

View In Hierarchy

Undocumented

Method __init__ Denote an attribute name as a synonym to a mapped property, in that the attribute will mirror the value and expression behavior of another attribute.
Method ​_comparator​_factory Undocumented
Method get​_history Undocumented
Method set​_parent Set the parent mapper that references this MapperProperty.
Instance Variable comparator​_factory Undocumented
Instance Variable descriptor Undocumented
Instance Variable doc Undocumented
Instance Variable info Undocumented
Instance Variable map​_column Undocumented
Instance Variable name Undocumented
Instance Variable parent Undocumented
Property ​_proxied​_object Undocumented
Property uses​_objects Undocumented

Inherited from DescriptorProperty:

Method instrument​_class Hook called by the Mapper to the property to initiate instrumentation of the class attribute managed by this MapperProperty.
Class Variable ​_links​_to​_entity True if this MapperProperty refers to a mapped entity.

Inherited from MapperProperty (via DescriptorProperty):

Method __repr__ Undocumented
Method ​_memoized​_attr​_info Info dictionary associated with the object, allowing user-defined data to be associated with this .InspectionAttr.
Method cascade​_iterator Iterate through instances related to the given instance for a particular 'cascade', starting with this MapperProperty.
Method create​_row​_processor Produce row processing functions and append to the given set of populators lists.
Method do​_init Perform subclass-specific initialization post-mapper-creation steps.
Method init Called after all mappers are created to assemble relationships between mappers and perform other post-mapper-creation initialization steps.
Method merge Merge the attribute represented by this MapperProperty from source to destination object.
Method post​_instrument​_class Perform instrumentation adjustments that need to occur after init() has completed.
Method setup Called by Query for the purposes of constructing a SQL statement.
Class Variable __slots__ Undocumented
Class Variable ​_cache​_key​_traversal Undocumented
Class Variable cascade The set of 'cascade' attribute names.
Class Variable is​_property Part of the InspectionAttr interface; states this object is a mapper property.
Instance Variable ​_configure​_finished Undocumented
Instance Variable ​_configure​_started Undocumented
Property class​_attribute Return the class-bound descriptor corresponding to this .MapperProperty.

Inherited from HasCacheKey (via DescriptorProperty, MapperProperty):

Class Variable inherit​_cache Indicate if this .HasCacheKey instance should make use of the cache key generation scheme used by its immediate superclass.
Class Method ​_generate​_cache​_attrs generate cache key dispatcher for a new class.
Class Method ​_generate​_cache​_key​_for​_object Undocumented
Method ​_gen​_cache​_key return an optional cache key.
Method ​_generate​_cache​_key return a cache key.
Class Variable ​_hierarchy​_supports​_caching private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses.
Class Variable ​_is​_has​_cache​_key Undocumented

Inherited from InspectionAttr (via DescriptorProperty, MapperProperty):

Class Variable ​_is​_internal​_proxy True if this object is an internal proxy object.
Class Variable is​_aliased​_class True if this object is an instance of .AliasedClass.
Class Variable is​_attribute True if this object is a Python :term:`descriptor`.
Class Variable is​_bundle True if this object is an instance of .Bundle.
Class Variable is​_clause​_element True if this object is an instance of _expression.ClauseElement.
Class Variable is​_instance True if this object is an instance of .InstanceState.
Class Variable is​_mapper True if this object is an instance of _orm.Mapper.
Class Variable is​_selectable Return True if this object is an instance of _expression.Selectable.

Inherited from MemoizedSlots (via DescriptorProperty, MapperProperty):

Method __getattr__ Undocumented
Method ​_fallback​_getattr Undocumented
def __init__(self, name, map_column=None, descriptor=None, comparator_factory=None, doc=None, info=None):

Denote an attribute name as a synonym to a mapped property, in that the attribute will mirror the value and expression behavior of another attribute.

e.g.:

class MyClass(Base):
    __tablename__ = 'my_table'

    id = Column(Integer, primary_key=True)
    job_status = Column(String(50))

    status = synonym("job_status")

See Also

:ref:`synonyms` - Overview of synonyms

.synonym_for - a helper oriented towards Declarative

:ref:`mapper_hybrids` - The Hybrid Attribute extension provides an updated approach to augmenting attribute behavior more flexibly than can be achieved with synonyms.

Parameters
namethe name of the existing mapped property. This can refer to the string name ORM-mapped attribute configured on the class, including column-bound attributes and relationships.
map​_column

For classical mappings and mappings against an existing Table object only. if True, the .synonym construct will locate the _schema.Column object upon the mapped table that would normally be associated with the attribute name of this synonym, and produce a new .ColumnProperty that instead maps this _schema.Column to the alternate name given as the "name" argument of the synonym; in this way, the usual step of redefining the mapping of the _schema.Column to be under a different name is unnecessary. This is usually intended to be used when a _schema.Column is to be replaced with an attribute that also uses a descriptor, that is, in conjunction with the :paramref:`.synonym.descriptor` parameter:

my_table = Table(
    "my_table", metadata,
    Column('id', Integer, primary_key=True),
    Column('job_status', String(50))
)

class MyClass(object):
    @property
    def _job_status_descriptor(self):
        return "Status: %s" % self._job_status


mapper(
    MyClass, my_table, properties={
        "job_status": synonym(
            "_job_status", map_column=True,
            descriptor=MyClass._job_status_descriptor)
    }
)

Above, the attribute named _job_status is automatically mapped to the job_status column:

>>> j1 = MyClass()
>>> j1._job_status = "employed"
>>> j1.job_status
Status: employed

When using Declarative, in order to provide a descriptor in conjunction with a synonym, use the sqlalchemy.ext.declarative.synonym_for helper. However, note that the :ref:`hybrid properties <mapper_hybrids>` feature should usually be preferred, particularly when redefining attribute behavior.

descriptora Python :term:`descriptor` that will be used as a getter (and potentially a setter) when this attribute is accessed at the instance level.
comparator​_factory

A subclass of .PropComparator that will provide custom comparison behavior at the SQL expression level.

Note

For the use case of providing an attribute which redefines both Python-level and SQL-expression level behavior of an attribute, please refer to the Hybrid attribute introduced at :ref:`mapper_hybrids` for a more effective technique.

docUndocumented
info

Optional data dictionary which will be populated into the .InspectionAttr.info attribute of this object.

New in version 1.0.0.
def _comparator_factory(self, mapper):

Undocumented

def get_history(self, *arg, **kw):

Undocumented

@util.preload_module('sqlalchemy.orm.properties')
def set_parent(self, parent, init):

Set the parent mapper that references this MapperProperty.

This method is overridden by some subclasses to perform extra setup when the mapper is first known.

comparator_factory =

Undocumented

info =

Undocumented

map_column =

Undocumented

name =

Undocumented

@util.memoized_property
_proxied_object =

Undocumented

@property
uses_objects =