o znhF%@stdZddlmZddlmZddlmZddlmZddlmZddlm Z ddl m Z dd l m Z dd l m Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl%m&Z&ddl%m'Z'ddl%m(Z(dd l%m)Z)dd!l%m*Z*dd"l%m+Z+dd#lm,Z,dd$l-m.Z.dd%l-m/Z/dd&l-m0Z0dd'l-m1Z1dd(l-m2Z2dd)l-m3Z3dd*l-m4Z4dd+l-m5Z5d,d-lm6Z7d,d.lm-Z8d,d/l9m:Z:dQd1d2Z;e:e!d3Ze:ed8Z?e:e d9Z@d:d;ZAdd?ZCe:ed@Ze:e dAZDe:e dBZEe8jFdCdDdEdFdGZGdHdIZHejIjJZIejIjKZLejMjJZMejNjJZNejOjJZOejPjJZPejQjJZQejRjJZRejSjJZSejTjKZTejUjJZUejVjKZVejWjJZWejXjKZXejYjJZYejZjJZZej[jJZ[ej\jJZ\ej]jJZ]dJdKZ^dLdMZ_e:edNZ`dOdPZaeaebd0S)Rz Functional constructs for ORM configuration. See the SQLAlchemy object relational tutorial and mapper configuration documentation for an overview of how this module is used. )exc)mapper)strategy_options)AttributeExtension)MapperExtension)SessionExtension)ComparableProperty)CompositeProperty)SynonymProperty) EXT_CONTINUE)EXT_SKIP)EXT_STOP)PropComparator)_mapper_registry) class_mapperconfigure_mappers)Mapper) reconstructor) validatesColumnProperty) AliasOption)Bundle)Query)foreign)RelationshipProperty)remote)scoped_session)close_all_sessions)make_transient)make_transient_to_detached)object_session)Session) sessionmaker)Load)aliased)join) object_mapper) outerjoin)polymorphic_union) was_deleted) with_parent)with_polymorphic)sqlutil)public_factoryNcKs6|dd|dd|ddtdd|i|S) aCreate a new :class:`.Session` with no automation enabled by default. This function is used primarily for testing. The usual route to :class:`.Session` creation is via its constructor or the :func:`.sessionmaker` function. :param bind: optional, a single Connectable to use for all database access in the created :class:`~sqlalchemy.orm.session.Session`. :param \*\*kwargs: optional, passed through to the :class:`.Session` constructor. :returns: an :class:`~sqlalchemy.orm.session.Session` instance The defaults of create_session() are the opposite of that of :func:`sessionmaker`; ``autoflush`` and ``expire_on_commit`` are False, ``autocommit`` is True. In this sense the session acts more like the "classic" SQLAlchemy 0.3 session with these. Usage:: >>> from sqlalchemy.orm import create_session >>> session = create_session() It is recommended to use :func:`sessionmaker` instead of create_session(). autoflushF autocommitTexpire_on_commitbindN) setdefaultr#)r6kwargsr7r7B/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/__init__.pycreate_session?s   r;z.orm.relationshipcOt|i|S)z#A synonym for :func:`relationship`. relationship)argkwr7r7r:relationgsrAcKsd|d<t|fi|S)aiConstruct a dynamically-loading mapper property. This is essentially the same as using the ``lazy='dynamic'`` argument with :func:`relationship`:: dynamic_loader(SomeClass) # is the same as relationship(SomeClass, lazy="dynamic") See the section :ref:`dynamic_relationship` for more details on dynamic loading. dynamiclazyr=)argumentr@r7r7r:dynamic_loadermsrEz.orm.column_propertyz.orm.compositecKs||fS)aCreate a back reference with explicit keyword arguments, which are the same arguments one can send to :func:`relationship`. Used with the ``backref`` keyword argument to :func:`relationship` in place of a string argument, e.g.:: 'items':relationship( SomeItem, backref=backref('parent', lazy='subquery')) .. seealso:: :ref:`relationships_backref` r7)namer9r7r7r:backrefsrGcOst|ddi|S)aIndicate a column-based mapped attribute that by default will not load unless accessed. :param \*columns: columns to be mapped. This is typically a single :class:`.Column` object, however a collection is supported in order to support multiple columns mapped under the same attribute. :param \**kw: additional keyword arguments passed to :class:`.ColumnProperty`. .. seealso:: :ref:`deferred` deferredTr)columnsr@r7r7r:rHsrHcCstt}d|_|S)zIndicate an attribute that populates from a query-time SQL expression. .. versionadded:: 1.2 .. seealso:: :ref:`mapper_query_expression` ))query_expressionT)r_sqlnull strategy_key)propr7r7r:rJs rJz .orm.mapperz .orm.synonymz.orm.comparable_propertyz0.7zv:func:`.compile_mappers` is deprecated and will be removed in a future release. Please use :func:`.configure_mappers`)messagecCs tdS)zZInitialize the inter-mapper relationships of all mappers that have been defined. Nrr7r7r7r:compile_mapperss rPcCsltjz*tr(z t\}}|Wn tyYnwtsWtjdSWtjdStjw)aRemove all mappers from all classes. This function removes all instrumentation from classes and disposes of their associated mappers. Once called, the classes are unmapped and can be later re-mapped with new mappers. :func:`.clear_mappers` is *not* for normal use, as there is literally no valid usage for it outside of very specific testing scenarios. Normally, mappers are permanent structural components of user-defined classes, and are never discarded independently of their class. If a mapped class itself is garbage collected, its mapper is automatically disposed of as well. As such, :func:`.clear_mappers` is only for usage in test suites that re-use the same classes with different mappings, which is itself an extremely rare use case - the only such use case is in fact SQLAlchemy's own test suite, and possibly the test suites of other ORM extension libraries which intend to test various combinations of mapper construction upon a fixed set of classes. N) mapperlib_CONFIGURE_MUTEXacquirerpopitemdisposeKeyErrorrelease)rbr7r7r: clear_mapperss    rYcOr<)z#A synonym for :func:`joinedload()`.) joinedloadargsr9r7r7r: eagerloadr]cOr<)z&A synonym for :func:`joinedload_all()`)joinedload_allr[r7r7r: eagerload_all r^r`z.orm.contains_aliascsnddlm}ddlm}ddlm}ddlm}ddltfdd |Dat j d t j d dS) Nr.r0r)rB)events)loadingc3s,|]\}}|ds|s|VqdS)_N) startswithismodule).0rFobj_inspectr7r: s z__go..zsqlalchemy.ormzsqlalchemy.ext) r1rBrarbinspectsorteditems__all___sa_util dependencies resolve_all)lclssa_utilrBrarbr7rir:__gos      rv)N)c__doc__rlrrrQrdeprecated_interfacesrrrdescriptor_propsrr r interfacesr r r rrrrrrr propertiesrqueryrrr relationshipsrrrscopingrsessionrr r!r"r#r$r%r1r&r'r(r)r*r+r,r-r/rKrqutil.langhelpersr2r;r>rArEcolumn_property compositerGrHrJsynonymcomparable_property deprecatedrPrYrZ _unbound_fn_unbound_all_fnr_contains_eagerdeferundefer undefer_groupwith_expression load_onlylazyload lazyload_all subqueryloadsubqueryload_all selectinloadselectinload_all immediateloadnoload raiseload defaultloadselectin_polymorphicr]r`contains_aliasrvlocalsr7r7r7r:s                                               %     !