class SynonymProperty(DescriptorProperty):
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 |
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 | |
name | the 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 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
|
descriptor | a 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 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. |
doc | Undocumented |
info | Optional data dictionary which will be populated into the
New in version 1.0.0.
|
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.