ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ 4]c @sddlZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZed@Zd"efd#YZ d$Z!d%e"d&Z#d'Z$d(ej%fd)YZ&d*e'fd+YZ(d,e fd-YZ)ej*e(d.ej*e)d/dde,e,d0Z-e,e,de,e,e,dd1Z.dd2Z/d3Z0d4Z1d5ej2fd6YZ3de,e,dd7Z4de,dd8Z5dd9Z6d:Z7d;Z8d<Z9d=Z:d>Z;d?Z<dS(AiNi(t attributes(t_class_to_mapper(t _never_set(t _none_set(t attribute_str(t class_mapper(tInspectionAttr(t instance_str(t object_mapper(t object_state(tstate_attribute_str(tstate_class_str(t state_str(tMapperProperty(tPropComparator(t PathRegistryi(tevent(texc(t inspection(tsql(tutil(t expressiontdeletes delete-orphantalltmergetexpunges save-updatesrefresh-expiretnonetCascadeOptionscBsSeZdZejdddgZeZd Zd Zd Z e d Z RS(s9Keeps track of the options sent to relationship().cascadeRRs delete-orphant save_updateRtrefresh_expireRRt delete_orphancCskt|tjs|dkr+|j|St|}|j|jrtj ddj gt |j|jD]}t |^qqnd|kr|j |jnd|kr|jn|jdtjt|}d|k|_d|k|_d|k|_d|k|_d |k|_d |k|_|jrg|j rgtjd n|S( NsInvalid cascade option(s): %ss, RRs save-updateRsrefresh-expireRRs delete-orphans5The 'delete-orphan' cascade option requires 'delete'.(t isinstanceRt string_typestNonet from_stringtsett differencet_allowed_cascadestsa_exct ArgumentErrortjointsortedtreprtupdatet_add_w_all_cascadestcleartdiscardt frozensett__new__RRRRRRRtwarn(tclst value_listtvaluestxtself((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR0Ds4  5     cCs*ddjgt|D] }|^qS(NsCascadeOptions(%r)t,(R(R)(R6R5((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt__repr__iscCs;gtjd|pdD]}|r|^q}||S(Ns\s*,\s*t(tretsplit(R2targtcR4((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR"ls1(RRRRRR( t__name__t __module__t__doc__t all_cascadesR$R,R%t __slots__R0R8t classmethodR"(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR3s % c sLsfdn|rfd}fd}fd}fd}nHfd}fd}fd}tj|d |d td ttj|d |d ttj|d |d td t|rHtj|d|d td tndS(sNRuns a validation method on an attribute value to be set or appended. cs|jj}|j|k S(N(tmanagertimpl(tstatet initiatorRE(tkey(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytdetect_is_backrefyscsI|jtjk rAs(|| rA|j|tS|SdS(N(topRtOP_BULK_REPLACEtobjtFalse(RFtvalueRG(RItinclude_backrefsRHt validator(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytappendscsRs|| rN|j}g|D]}||t^q)|(ndS(N(RLRM(RFR4RGRLRN(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytbulk_sets cs7s|| r/|j|tS|SdS(N(RLRM(RFRNtoldvalueRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytset_scs6s|| r2|j|tndS(N(RLtTrue(RFRNRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytremovescsF|jtjk r>s(|| r>|j|S|SdS(N(RJRRKRL(RFRNRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRQscsOs|| rK|j}g|D]}||^q)|(ndS(N(RL(RFR4RGRLRN(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRRs cs4s|| r,|j|S|SdS(N(RL(RFRNRSRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRTsRQtrawtretvalt bulk_replaceR#RVN(RtlistenRU( tdescRHRPtinclude_removesRORQRRRTRV((RIRORHRPsF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_validator_eventsrstp_unionc stj}iix|D]}||}t|tjrZ|j}||||jD]3}|j|j|||j<|j |j>> identity_key(MyClass, (1, 2)) (, (1, 2), None) :param class: mapped class (must be a positional argument) :param ident: primary key, may be a scalar or tuple argument. :param identity_token: optional identity token .. versionadded:: 1.2 added identity_token * ``identity_key(instance=instance)`` This form will produce the identity key for a given instance. The instance need not be persistent, only that its primary key attributes are populated (else the key will contain ``None`` for those missing values). E.g.:: >>> instance = MyClass(1, 2) >>> identity_key(instance=instance) (, (1, 2), None) In this form, the given instance is ultimately run though :meth:`.Mapper.identity_key_from_instance`, which will have the effect of performing a database check for the corresponding row if the object is expired. :param instance: object instance (must be given as a keyword arg) * ``identity_key(class, row=row, identity_token=token)`` This form is similar to the class/tuple form, except is passed a database result row as a :class:`.RowProxy` object. E.g.:: >>> row = engine.execute("select * from table where a=1 and b=2").first() >>> identity_key(MyClass, row=row) (, (1, 2), None) :param class: mapped class (must be a positional argument) :param row: :class:`.RowProxy` row returned by a :class:`.ResultProxy` (must be given as a keyword arg) :param identity_token: optional identity token .. versionadded:: 1.2 added identity_token iitrowtidentiis1expected up to three positional arguments, got %stidentity_tokensunknown keyword arguments: %ss, tinstanceN(ii(R!tlentpopR_R&R'R(Rtidentity_key_from_primary_keyRtto_listtidentity_key_from_rowtkeysRtidentity_key_from_instance( targstkwargsR~tlargstclass_RRtmapperR((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt identity_keys:?         t ORMAdaptercBs,eZdZdeeedZdZRS(saColumnAdapter subclass which excludes adaptation of entities from non-matching mappers. c Cs}tj|}|j|_|j}|j}|r?||_n d|_tjj |||d|d|d|d|j dS(Ntadapt_requiredtallow_label_resolvetanonymize_labelst include_fn( RtinspectRt selectabletis_aliased_classt aliased_classR!Rst ColumnAdaptert__init__t _include_fn( R6tentityt equivalentsRRRtinfoRR((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRjs      cCs,|jjdd}| p+|j|jS(Nt parentmapper(t _annotationstgetR!tisaR(R6telemR((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRsN(R>R?R@R!RMRURR(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRds  t AliasedClassc BsMeZdZddeedddeed ZdZdZdZRS(sRepresents an "aliased" form of a mapped class for usage with Query. The ORM equivalent of a :func:`~sqlalchemy.sql.expression.alias` construct, this object mimics the mapped class using a ``__getattr__`` scheme and maintains a reference to a real :class:`~sqlalchemy.sql.expression.Alias` object. A primary purpose of :class:`.AliasedClass` is to serve as an alternate within a SQL statement generated by the ORM, such that an existing mapped entity can be used in multiple contexts. A simple example:: # find all pairs of users with the same name user_alias = aliased(User) session.query(User, user_alias).\ join((user_alias, User.id > user_alias.id)).\ filter(User.name == user_alias.name) :class:`.AliasedClass` is also capable of mapping an existing mapped class to an entirely new selectable, provided this selectable is column- compatible with the existing mapped selectable, and it can also be configured in a mapping as the target of a :func:`.relationship`. See the links below for examples. The :class:`.AliasedClass` object is constructed typically using the :func:`.orm.aliased` function. It also is produced with additional configuration when using the :func:`.orm.with_polymorphic` function. The resulting object is an instance of :class:`.AliasedClass`. This object implements an attribute scheme which produces the same attribute and method interface as the original mapped class, allowing :class:`.AliasedClass` to be compatible with any attribute technique which works on the original class, including hybrid attributes (see :ref:`hybrids_toplevel`). The :class:`.AliasedClass` can be inspected for its underlying :class:`.Mapper`, aliased selectable, and other information using :func:`.inspect`:: from sqlalchemy import inspect my_alias = aliased(MyClass) insp = inspect(my_alias) The resulting inspection object is an instance of :class:`.AliasedInsp`. .. seealso:: :func:`.aliased` :func:`.with_polymorphic` :ref:`relationship_aliased_class` :ref:`relationship_to_window_function` c Cst|} |dkr6| jjd|d|}nt|| |||rQ|n| j|dk ri|n| j|| || |_d| jj |_ dS(NRdtflatsAliasedClass_%s( RR!t_with_polymorphic_selectableRmt AliasedInsptwith_polymorphic_mapperstpolymorphic_ont _aliased_inspRR>( R6R2RmRdRtadapt_on_namesRtwith_polymorphic_discriminatort base_aliastuse_mapper_pathtrepresents_outer_joinR((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRs$     cCsy|jd}Wntk r-tnX|j}t||}t|drwt|drwtj|j|St|dr|j d|}nt|dr|j |}t |||n|S(NRt__call__t__self__t__get__tadapt_to_entity( t__dict__R_tAttributeErrort_targettgetattrthasattrRht MethodTypet__func__RR!Rtsetattr(R6RHRttargettattr((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt __getattr__s   cCsdt||jjjfS(Ns(tidRRR>(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR8 s cCs t|jS(N(tstrR(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt__str__sN(( R>R?R@R!RMRRR8R(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRs9   RcBseZdZdZeZedZej dZ dZ dZ dZ dZej dZej d Zd Zd Zd ZRS( sProvide an inspection interface for an :class:`.AliasedClass` object. The :class:`.AliasedInsp` object is returned given an :class:`.AliasedClass` using the :func:`.inspect` function:: from sqlalchemy import inspect from sqlalchemy.orm import aliased my_alias = aliased(MyMappedClass) insp = inspect(my_alias) Attributes on :class:`.AliasedInsp` include: * ``entity`` - the :class:`.AliasedClass` represented. * ``mapper`` - the :class:`.Mapper` mapping the underlying class. * ``selectable`` - the :class:`.Alias` construct which ultimately represents an aliased :class:`.Table` or :class:`.Select` construct. * ``name`` - the name of the alias. Also is used as the attribute name when returned in a result tuple from :class:`.Query`. * ``with_polymorphic_mappers`` - collection of :class:`.Mapper` objects indicating all those mappers expressed in the select construct for the :class:`.AliasedClass`. * ``polymorphic_on`` - an alternate column or SQL expression which will be used as the "discriminator" for a polymorphic load. .. seealso:: :ref:`inspection_toplevel` c CsH||_||_||_|_|_||_||_|pD||_||_| |_ |rt |_ ||_ g|_ x|j D]e} | |k rt| j|d|d| d|} t|j| jj| |j j| jqqWnt|_ |g|_ tj|d|jd| dt |_| |_|j|_dS(NRRRRR(RRRtpersist_selectablet local_tableRdRt _base_aliast_use_mapper_pathRRUt_is_with_polymorphicRt_with_polymorphic_entitiesRRRR>RQRRMRsRt_equivalent_columnst_adaptert_adapt_on_namesR( R6RRRRdRRRRRRtpolytent((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR8s>                cCs |jjS(sUReturn the mapped class ultimately represented by this :class:`.AliasedInsp`.(RR(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRrscCs$|jr|jjStj|SdS(N(RRt_path_registryRt per_mapper(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRxs  cCshi |jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd 6|j d 6S( NRRRmRdRRRRRR( RRRRdRRRRRR(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt __getstate__s         c CsT|j|d|d|d|d|d|d|d|d|d |d  dS( NRRRmRdRRRRRR(R(R6RF((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt __setstate__scCs*|jj|ji|d6|jd6S(Nt parententityR(Rttraverset _annotateR(R6R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_adapt_elementscCsz|j}||krD||jkr(|St|j|jjjSn2|j|jrZ|Stsvt d||fdS(Ns"mapper %s doesn't correspond to %s( RRRRRR>RRRMtAssertionError(R6Rt self_poly((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_entity_for_mappers  cs>jj\}}jj|fd|jDfS(Ncs+i|]!\}}|jj|qS((RR(t.0Ritparam(R6(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pys s (Rt _get_clauseRRRp(R6tonclauset replacemap((R6sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRs cCsiS(N((R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_memoized_valuesscOs<||jkr|j|S||||j|<}|SdS(N(R(R6RHt callable_RtkwRN((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_memos cCsO|jr,ddjd|jD}nd}dt||jj|fS(Ns(%s)s, css|]}|jjVqdS(N(RR>(Rtmp((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pys sR9s(RR(RRR>(R6t with_poly((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR8s    csNjr9djjdjfdjDfSdjjfSdS(Nswith_polymorphic(%s, [%s])s, c3s*|] }|jk r|jjVqdS(N(RRR>(RR(R6(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pys ss aliased(%s)(RRR>R(R(R6((R6sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRs   (R>R?R@RRURtpropertyRRtmemoized_propertyRRRRRRRRR8R(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRs" 7       cCs|jS(N(R(R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytR9cCs|S(N((R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRR9c Csct|tjr=|r*tjdn|j|d|St|d|d|d|d|SdS(sgProduce an alias of the given element, usually an :class:`.AliasedClass` instance. E.g.:: my_alias = aliased(MyClass) session.query(MyClass, my_alias).filter(MyClass.id > my_alias.id) The :func:`.aliased` function is used to create an ad-hoc mapping of a mapped class to a new selectable. By default, a selectable is generated from the normally mapped selectable (typically a :class:`.Table`) using the :meth:`.FromClause.alias` method. However, :func:`.aliased` can also be used to link the class to a new :func:`.select` statement. Also, the :func:`.with_polymorphic` function is a variant of :func:`.aliased` that is intended to specify a so-called "polymorphic selectable", that corresponds to the union of several joined-inheritance subclasses at once. For convenience, the :func:`.aliased` function also accepts plain :class:`.FromClause` constructs, such as a :class:`.Table` or :func:`.select` construct. In those cases, the :meth:`.FromClause.alias` method is called on the object and the new :class:`.Alias` object returned. The returned :class:`.Alias` is not ORM-mapped in this case. :param element: element to be aliased. Is normally a mapped class, but for convenience can also be a :class:`.FromClause` element. :param alias: Optional selectable unit to map the element to. This should normally be a :class:`.Alias` object corresponding to the :class:`.Table` to which the class is mapped, or to a :func:`.select` construct that is compatible with the mapping. By default, a simple anonymous alias of the mapped table is generated. :param name: optional string name to use for the alias, if not specified by the ``alias`` parameter. The name, among other things, forms the attribute name that will be accessible via tuples returned by a :class:`.Query` object. :param flat: Boolean, will be passed through to the :meth:`.FromClause.alias` call so that aliases of :class:`.Join` objects don't include an enclosing SELECT. This can lead to more efficient queries in many circumstances. A JOIN against a nested JOIN will be rewritten as a JOIN against an aliased SELECT subquery on backends that don't support this syntax. .. versionadded:: 0.9.0 .. seealso:: :meth:`.Join.alias` :param adapt_on_names: if True, more liberal "matching" will be used when mapping the mapped columns of the ORM entity to those of the given selectable - a name-based match will be performed if the given selectable doesn't otherwise have a column that corresponds to one on the entity. The use case for this is when associating an entity with some derived selectable such as one that uses aggregate functions:: class UnitPrice(Base): __tablename__ = 'unit_price' ... unit_id = Column(Integer) price = Column(Numeric) aggregated_unit_price = Session.query( func.sum(UnitPrice.price).label('price') ).group_by(UnitPrice.unit_id).subquery() aggregated_unit_price = aliased(UnitPrice, alias=aggregated_unit_price, adapt_on_names=True) Above, functions on ``aggregated_unit_price`` which refer to ``.price`` will return the ``func.sum(UnitPrice.price).label('price')`` column, as it is matched on the name "price". Ordinarily, the "price" function wouldn't have any "column correspondence" to the actual ``UnitPrice.price`` column as it is not a proxy of the original. s+adapt_on_names only applies to ORM elementsRRmRdRN(RRt FromClauseR&R'RmR(telementRmRdRR((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytaliasedsP c Cst|} |r}|j| ks'ttj|}tg|jD]} | j^qC} || krk|S|j| }n| j ||d|\} }|s|r|j d|}nt ||d| d|d|d| S(s Produce an :class:`.AliasedClass` construct which specifies columns for descendant mappers of the given base. Using this method will ensure that each descendant mapper's tables are included in the FROM clause, and will allow filter() criterion to be used against those tables. The resulting instances will also have those columns already loaded so that no "post fetch" of those columns will be required. .. seealso:: :ref:`with_polymorphic` - full discussion of :func:`.orm.with_polymorphic`. :param base: Base class to be aliased. :param classes: a single class or mapper, or list of class/mappers, which inherit from the base class. Alternatively, it may also be the string ``'*'``, in which case all descending mapped classes will be added to the FROM clause. :param aliased: when True, the selectable will be wrapped in an alias, that is ``(SELECT * FROM ) AS anon_1``. This can be important when using the with_polymorphic() to create the target of a JOIN on a backend that does not support parenthesized joins, such as SQLite and older versions of MySQL. However if the :paramref:`.with_polymorphic.selectable` parameter is in use with an existing :class:`.Alias` construct, then you should not set this flag. :param flat: Boolean, will be passed through to the :meth:`.FromClause.alias` call so that aliases of :class:`.Join` objects don't include an enclosing SELECT. This can lead to more efficient queries in many circumstances. A JOIN against a nested JOIN will be rewritten as a JOIN against an aliased SELECT subquery on backends that don't support this syntax. Setting ``flat`` to ``True`` implies the ``aliased`` flag is also ``True``. .. versionadded:: 0.9.0 .. seealso:: :meth:`.Join.alias` :param selectable: a table or select() statement that will be used in place of the generated FROM clause. This argument is required if any of the desired classes use concrete table inheritance, since SQLAlchemy currently cannot generate UNIONs among tables automatically. If used, the ``selectable`` argument must represent the full set of tables and columns mapped by every mapped class. Otherwise, the unaccounted mapped columns will result in their table being appended directly to the FROM clause which will usually lead to incorrect results. :param polymorphic_on: a column to be used as the "discriminator" column for the given selectable. If not given, the polymorphic_on attribute of the base classes' mapper will be used, if any. This is useful for mappings that don't have polymorphic loading behavior by default. :param innerjoin: if True, an INNER JOIN will be used. This should only be specified if querying for one specific subtype only t innerjoinRRRRR( RRRRtto_setR#RRtuniont_with_polymorphic_argsRmR( tbasetclassesRRRRRRt_existing_aliastprimary_mapperRt new_classestmappers((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytwith_polymorphicCs(K "  cCstj|itd6|S(sDeep copy the given ClauseElement, annotating each element with the "_orm_adapt" flag. Elements within the exclude collection will be cloned but not annotated. t _orm_adapt(Rst_deep_annotateRU(Rtexclude((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt _orm_annotatescCstj|ddS(sRemove annotations that link a column to a particular mapping. Note this doesn't affect "remote" and "foreign" annotations passed by the :func:`.orm.foreign` and :func:`.orm.remote` annotators. R4RR(RR(Rst_deep_deannotate(R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_orm_deannotates cCs tj|S(N(RsR(R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_orm_full_deannotatest_ORMJoincBsbeZdZejjZdeedddZdZ deeddZ deddZ RS(s/Extend Join to support ORM constructs as input.c Cs5tj|}t|d|} tj|} | j} | |_||_||_t|tj r{t| j |}nt|t j r|j j} |j} n*t|tr|} | jj} nd} | rtj| |jr| }n |j}| jd|d| dtdtd| j\}}}}}}|dk r|rntj|||}|}qtj||||}|}n|}||_ntjj||||||| r1t| ddr1| jjr1| jj}|dk r1| j r| j!j"|}n|j#|@|_#q1ndS(Nt_joined_from_infotsource_selectabletdest_selectabletsource_polymorphictdest_polymorphictof_type_mapperR($RRRRRt _left_memot _right_memoRRR RRtQueryableAttributet comparatort_source_selectableRR tparentR!Rstclause_is_presentt _create_joinsRURRR(t_target_adapterRtJoinRtsinglet_single_table_criterionRRRR(R6tlefttrightRtisoutertfullRRt left_infot left_orm_infot right_infotadapt_tot on_selectabletpropt adapt_fromtpjtsjtsourcetdestt secondaryttarget_adaptert single_crit((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRsV                c Cs|}xt|tjr'|j}q W|j|ks=tt|j|j|jd|jd|j d|j }t||j|jd|jd|j S(slSplice a join into the center. Given join(a, b) and join(b, c), return join(a, b).join(c) RRR( RRR R RRRRRRR(R6tothertleftmostR ((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_splice_into_centers"       cCst|||d|d|S(NRR(R(R6RRRRt join_to_left((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR(8scCst|||dtd|S(NRR(RRU(R6RRRR"((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt outerjoinBsN( R>R?R@RR t__visit_name__R!RMRR!R(R#(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRs  J  cCst|||||S(sProduce an inner join between left and right clauses. :func:`.orm.join` is an extension to the core join interface provided by :func:`.sql.expression.join()`, where the left and right selectables may be not only core selectable objects such as :class:`.Table`, but also mapped classes or :class:`.AliasedClass` instances. The "on" clause can be a SQL expression, or an attribute or string name referencing a configured :func:`.relationship`. :func:`.orm.join` is not commonly needed in modern usage, as its functionality is encapsulated within that of the :meth:`.Query.join` method, which features a significant amount of automation beyond :func:`.orm.join` by itself. Explicit usage of :func:`.orm.join` with :class:`.Query` involves usage of the :meth:`.Query.select_from` method, as in:: from sqlalchemy.orm import join session.query(User).\ select_from(join(User, Address, User.addresses)).\ filter(Address.email_address=='foo@bar.com') In modern SQLAlchemy the above join can be written more succinctly as:: session.query(User).\ join(User.addresses).\ filter(Address.email_address=='foo@bar.com') See :meth:`.Query.join` for information on modern usage of ORM level joins. .. deprecated:: 0.8 the ``join_to_left`` parameter is deprecated, and will be removed in a future release. The parameter has no effect. (R(R RRRRR"((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR(Fs*cCst|||t|S(sProduce a left outer join between left and right clauses. This is the "outer join" version of the :func:`.orm.join` function, featuring the same behavior except that an OUTER JOIN is generated. See that function's documentation for other usage details. (RRU(R RRRR"((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR#sscCsgt|tjr6t|}t|j|j}nt|tjrT|j}n|j |d|S(sCreate filtering criterion that relates this query's primary entity to the given related instance, using established :func:`.relationship()` configuration. The SQL rendered is the same as that rendered when a lazy loader would fire off from the given parent on that attribute, meaning that the appropriate state is taken from the parent object in Python without the need to render joins to the parent table in the rendered statement. :param instance: An instance which has some :func:`.relationship`. :param property: String property name, or class-bound attribute, which indicates what relationship from the instance should be used to reconcile the parent/child relationship. :param from_entity: Entity in which to consider as the left side. This defaults to the "zero" entity of the :class:`.Query` itself. .. versionadded:: 1.2 t from_entity( RRR RRRRRRt _with_parent(RRR%R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt with_parent~s   cCstj|}|jS(sReturn True if the given object has a database identity. This typically corresponds to the object being in either the persistent or detached state. .. seealso:: :func:`.was_deleted` (Rtinstance_statet has_identity(tobject_RF((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR)s cCstj|}|jS(sReturn True if the given object was deleted within a session flush. This is regardless of whether or not the object is persistent or detached. .. seealso:: :attr:`.InstanceState.was_deleted` (RR(t was_deleted(R*RF((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR+s cCsh|jr/|jr+|j|jkr+tSntS|jr[|jrN||jkS||kSn|j|S(sdetermine if 'given' corresponds to 'entity', in terms of an entity passed to Query that would match the same entity being referred to elsewhere in the query. (RRRURMRRt common_parent(tgivenR((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_entity_corresponds_tos      cCsh|jr5|jo4|j o4||kp4||jkS|jsN|j|jS|joc||jkSdS(sdetermine if 'given' corresponds to 'entity', in terms of a path of loader options where a mapped attribute is taken to be a member of a parent entity. e.g.:: someoption(A).someoption(A.b) # -> fn(A, A) -> True someoption(A).someoption(C.d) # -> fn(A, C) -> False a1 = aliased(A) someoption(a1).someoption(A.b) # -> fn(a1, A) -> False someoption(a1).someoption(a1.b) # -> fn(a1, a1) -> True wp = with_polymorphic(A, [A1, A2]) someoption(wp).someoption(A1.foo) # -> fn(wp, A1) -> False someoption(wp).someoption(wp.A1.foo) # -> fn(wp, wp.A1) -> True N(RRRR,RR(R-R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt$_entity_corresponds_to_use_path_impls     cCsO|jr(||jkp'|jj|S|jr>||jkS|j|SdS(sedetermine if 'given' "is a" mapper, in terms of the given would load rows of type 'mapper'. N(RRRR(R-R((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt _entity_isas    cCskddlm}m}m}m}ddlm}ddlm}||_ |_ |_ |_ |_ dS(sZUse random-ordering sets within the unit of work in order to detect unit of work sorting issues. This is a utility function that can be used to help reproduce inconsistent unit of work sorting issues. For example, if two kinds of objects A and B are being inserted, and B has a foreign key reference to A - the A must be inserted first. However, if there is no relationship between A and B, the unit of work won't know to perform this sorting, and an operation may or may not fail, depending on how the ordering works out. Since Python sets and dictionaries have non-deterministic ordering, such an issue may occur on some runs and not on others, and in practice it tends to have a great dependence on the state of the interpreter. This leads to so-called "heisenbugs" where changing entirely irrelevant aspects of the test program still cause the failure behavior to change. By calling ``randomize_unitofwork()`` when a script first runs, the ordering of a key series of sets within the unit of work implementation are randomized, so that the script can be minimized down to the fundamental mapping and operation that's failing, while still reproducing the issue on at least some runs. This utility is also available when running the test suite via the ``--reversetop`` flag. i(t unitofworktsessionRt dependency(t topological(t RandomSetN( tsqlalchemy.ormR1R2RR3tsqlalchemy.utilR4tsqlalchemy.testing.utilR5R#(R1R2RR3R4R5((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytrandomize_unitofworks"(Rs delete-orphanRRRs save-updatesrefresh-expireR(=R:RhR9RRRRRRRRRRR R R R t interfacesR Rt path_registryRRRR&RRRRRsR/RARR]RUR}RRRtobjectRRt _inspectsR!RMRRRRRR RR(R#R'R)R+R.R/R0R9(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt s~   ? CH g'c \  , #    #