B 4]F%@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_mapper)configure_mappers)Mapper) reconstructor) validates)ColumnProperty) 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)sql)util)public_factoryNcKs6|dd|dd|ddtfd|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(). Z autoflushFZ autocommitTZexpire_on_commitbind) setdefaultr!)r0kwargsr3J/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/orm/__init__.pycreate_session?s   r5z.orm.relationshipcOs t||S)z#A synonym for :func:`relationship`.) relationship)argkwr3r3r4relationgsr9cKsd|d<t|f|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. dynamicZlazy)r6)Zargumentr8r3r3r4dynamic_loadermsr;z.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` r3)namer2r3r3r4backrefsr=cOst|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` deferredT)r)columnsr8r3r3r4r>sr>cCstt}d|_|S)zIndicate an attribute that populates from a query-time SQL expression. .. versionadded:: 1.2 .. seealso:: :ref:`mapper_query_expression` ))query_expressionT)r_sqlZnullZ strategy_key)Zpropr3r3r4r@s r@z .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. N)rr3r3r3r4compile_mapperss rCcCsXtjzYqXqWWdtjXdS)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) mapperlibZ_CONFIGURE_MUTEXacquirerpopitemZdisposeKeyErrorrelease)rbr3r3r4 clear_mapperss   rJcOs t||S)z#A synonym for :func:`joinedload()`.) joinedload)argsr2r3r3r4 eagerloadsrMcOs t||S)z&A synonym for :func:`joinedload_all()`)joinedload_all)rLr2r3r3r4 eagerload_all srOz.orm.contains_aliascsnddlm}ddlm}ddlm}ddlm}ddltfdd |Dat j d t j d dS) Nr,)r.r)r:)events)loadingc3s*|]"\}}|ds|s|VqdS)_N) startswithZismodule).0r<obj)_inspectr3r4 sz__go..zsqlalchemy.ormzsqlalchemy.ext) r.r:rPrQinspectsorteditems__all___sa_utilZ dependenciesZ resolve_all)ZlclsZsa_utilr:rPrQr3)rWr4__gos      r_)N)c__doc__rYrrrDrZdeprecated_interfacesrrrZdescriptor_propsrr r Z interfacesr r r rrrrrrrZ propertiesrZqueryrrrZ relationshipsrrrZscopingrZsessionrrrr r!r"r#r.r$r%r&r'r(r)r*r+r-rAr^Zutil.langhelpersr/r5r6r9r;Zcolumn_propertyZ compositer=r>r@ZsynonymZcomparable_propertyZ deprecatedrCrJrKZ _unbound_fnZ_unbound_all_fnrNZcontains_eagerZdeferZundeferZ undefer_groupZwith_expressionZ load_onlyZlazyloadZ lazyload_allZ subqueryloadZsubqueryload_allZ selectinloadZselectinload_allZ immediateloadZnoloadZ raiseloadZ defaultloadZselectin_polymorphicrMrOZcontains_aliasr_localsr3r3r3r4s                                              %      !