MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / attrs

Method attrs

lib/sqlalchemy/orm/mapper.py:3024–3059  ·  view source on GitHub ↗

A namespace of all :class:`.MapperProperty` objects associated this mapper. This is an object that provides each property based on its key name. For instance, the mapper for a ``User`` class which has ``User.name`` attribute would provide ``mapper.attrs.name

(self)

Source from the content-addressed store, hash-verified

3022
3023 @HasMemoized.memoized_attribute
3024 def attrs(self) -> util.ReadOnlyProperties[MapperProperty[Any]]:
3025 """A namespace of all :class:`.MapperProperty` objects
3026 associated this mapper.
3027
3028 This is an object that provides each property based on
3029 its key name. For instance, the mapper for a
3030 ``User`` class which has ``User.name`` attribute would
3031 provide ``mapper.attrs.name``, which would be the
3032 :class:`.ColumnProperty` representing the ``name``
3033 column. The namespace object can also be iterated,
3034 which would yield each :class:`.MapperProperty`.
3035
3036 :class:`_orm.Mapper` has several pre-filtered views
3037 of this attribute which limit the types of properties
3038 returned, including :attr:`.synonyms`, :attr:`.column_attrs`,
3039 :attr:`.relationships`, and :attr:`.composites`.
3040
3041 .. warning::
3042
3043 The :attr:`_orm.Mapper.attrs` accessor namespace is an
3044 instance of :class:`.OrderedProperties`. This is
3045 a dictionary-like object which includes a small number of
3046 named methods such as :meth:`.OrderedProperties.items`
3047 and :meth:`.OrderedProperties.values`. When
3048 accessing attributes dynamically, favor using the dict-access
3049 scheme, e.g. ``mapper.attrs[somename]`` over
3050 ``getattr(mapper.attrs, somename)`` to avoid name collisions.
3051
3052 .. seealso::
3053
3054 :attr:`_orm.Mapper.all_orm_descriptors`
3055
3056 """
3057
3058 self._check_configure()
3059 return util.ReadOnlyProperties(self._props)
3060
3061 @HasMemoized.memoized_attribute
3062 def all_orm_descriptors(self) -> util.ReadOnlyProperties[InspectionAttr]:

Callers

nothing calls this directly

Calls 1

_check_configureMethod · 0.95

Tested by

no test coverage detected