%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyc

�
��4]c	@sddlZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm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,d0�Z-e,e,de,e,e,dd1�Z.dd2�Z/d3�Z0d4�Z1d5ej2fd6��YZ3de,e,dd7�Z4de,dd8�Z5dd9�Z6d:�Z7d;�Z8d<�Z9d=�Z:d>�Z;d?�Z<dS(Ai����Ni(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-orphantalltmergetexpungessave-updatesrefresh-expiretnonetCascadeOptionscBsSeZdZejdddg�ZeZd
Zd
�Zd�Z	e
d��ZRS(s9Keeps track of the options sent to relationship().cascadeRRs
delete-orphantsave_updateRtrefresh_expireRRt
delete_orphancCskt|tj�s|dkr+|j|�St|�}|j|j�r�tj	ddj
gt|j|j��D]}t|�^qq���nd|kr�|j
|j�nd|kr�|j�n|jd�tjt|�}d|k|_d|k|_d|k|_d|k|_d	|k|_d
|k|_|jrg|jrgtjd�n|S(NsInvalid cascade option(s): %ss, RRssave-updateRsrefresh-expireRRs
delete-orphans5The 'delete-orphan' cascade option requires 'delete'.(t
isinstanceRtstring_typestNonetfrom_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]}|^q�S(NsCascadeOptions(%r)t,(R(R)(R6R5((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt__repr__iscCs;gtjd|pd�D]}|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__R0R8tclassmethodR"(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR3s	%	c	sL�s�fd��n|r�����fd�}����fd�}����fd�}����fd�}nH����fd�}����fd�}����fd�}tj|d	|d
tdt�tj|d|d
t�tj|d
|d
tdt�|rHtj|d|d
tdt�ndS(sNRuns a validation method on an attribute value to be set or
    appended.
    cs|j�j}|j|k	S(N(tmanagertimpl(tstatet	initiatorRE(tkey(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytdetect_is_backrefyscsI|jtjk	rA�s(�||�rA�|j��|t�S|SdS(N(topRtOP_BULK_REPLACEtobjtFalse(RFtvalueRG(RItinclude_backrefsRHt	validator(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytappendscsR�s�||�rN|j�}g|D]}�|�|t�^q)|(ndS(N(RLRM(RFR4RGRLRN(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytbulk_set�scs7�s�||�r/�|j��|t�S|SdS(N(RLRM(RFRNtoldvalueRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytset_�scs6�s�||�r2�|j��|t�ndS(N(RLtTrue(RFRNRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytremove�scsF|jtjk	r>�s(�||�r>�|j��|�S|SdS(N(RJRRKRL(RFRNRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRQ�scsO�s�||�rK|j�}g|D]}�|�|�^q)|(ndS(N(RL(RFR4RGRLRN(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRR�scs4�s�||�r,�|j��|�S|SdS(N(RL(RFRNRSRG(RIRORHRP(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyRT�sRQtrawtretvaltbulk_replaceR#RVN(RtlistenRU(	tdescRHRPtinclude_removesRORQRRRTRV((RIRORHRPsF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_validator_eventsrstp_unionc
s�tj�}i�i�x�|D]�}||}t|tj�rZ|j�}|||<ni}x>|jD]3}|j|j�|||j<|j	�|j<qjW|�|<qW���fd�}	g}
x�|j
�D]�\}}|dk	rO|
jtj
g|D]}|	||�^qtjtj|��j|�gd|g��q�|
jtj
g|D]}|	||�^qbd|g��q�Wtj|
�j|�S(s)Create a ``UNION`` statement used by a polymorphic mapper.

    See  :ref:`concrete_inheritance` for an example of how
    this is used.

    :param table_map: mapping of polymorphic identities to
     :class:`.Table` objects.
    :param typecolname: string name of a "discriminator" column, which will be
     derived from the query, producing the polymorphic identity for
     each row.  If ``None``, no polymorphic discriminator is generated.
    :param aliasname: name of the :func:`~sqlalchemy.sql.expression.alias()`
     construct generated.
    :param cast_nulls: if True, non-existent columns, which are represented
     as labeled NULLs, will be passed into CAST.   This is a legacy behavior
     that is problematic on some backends such as Oracle - in which case it
     can be set to False.

    csty�||SWn]tk
ro�rItjtj��|�j|�Stjtj��|�j|�SnXdS(N(tKeyErrorRtcasttnulltlabelttype_coerce(tnamettable(t
cast_nullstcolnamemapsttypes(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytcol�s
#tfrom_objN(Rt
OrderedSetRRtSelecttaliasR=taddRHttypetitemsR!RQtselecttliteral_columntsql_utilt_quote_ddl_exprRbt	union_all(
t	table_mapttypecolnamet	aliasnameRftcolnamesRHRetmR=Ritresultttype_Rd((RfRgRhsF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytpolymorphic_union�s:



	
3c	Osj|rd}t|�}|dkrg|d}y|jd�}Wq�tk
rc|jd�}q�Xn.|d
kr�|\}}ntjd|��|jdd�}|r�tjd	d
j|���nt|�}|dkr|jt	j
|�d|�S|j|d|�SnP|jd�}|rMtjd	d
j|j���nt
|�}|j|�SdS(sGenerate "identity key" tuples, as are used as keys in the
    :attr:`.Session.identity_map` dictionary.

    This function has several call styles:

    * ``identity_key(class, ident, identity_token=token)``

      This form receives a mapped class and a primary key scalar or
      tuple as an argument.

      E.g.::

        >>> identity_key(MyClass, (1, 2))
        (<class '__main__.MyClass'>, (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)
        (<class '__main__.MyClass'>, (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)
        (<class '__main__.MyClass'>, (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_RR�tmapperR�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytidentity_key�s:?


t
ORMAdaptercBs,eZdZdeeed�Zd�ZRS(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(RtinspectR�t
selectabletis_aliased_classt
aliased_classR!Rst
ColumnAdaptert__init__t_include_fn(	R6tentitytequivalentsR�R�R�tinfoR�R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR�js				cCs,|jjdd�}|p+|j|j�S(Ntparentmapper(t_annotationstgetR!tisaR�(R6telemR�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��sN(R>R?R@R!RMRUR�R�(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR�dstAliasedClassc
BsMeZdZddeedddeed�	Zd�Zd�Zd�ZRS(s�Represents 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Cs�t|�}|dkr6|jjd|d|�}nt|||||rQ|n|j|dk	ri|n|j||	||
�
|_d|jj	|_	dS(NRdtflatsAliasedClass_%s(
RR!t_with_polymorphic_selectableRmtAliasedInsptwith_polymorphic_mapperstpolymorphic_ont
_aliased_inspR�R>(R6R2RmRdR�tadapt_on_namesR�twith_polymorphic_discriminatort
base_aliastuse_mapper_pathtrepresents_outer_joinR�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��s$cCs�y|jd}Wntk
r-t��nX|j}t||�}t|d�rwt|d�rwtj|j|�St|d�r�|j	d|�}nt|d�r�|j|�}t|||�n|S(NR�t__call__t__self__t__get__tadapt_to_entity(
t__dict__R_tAttributeErrort_targettgetattrthasattrRht
MethodTypet__func__R�R!R�tsetattr(R6RHR�ttargettattr((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt__getattr__�s

	cCsdt|�|jjjfS(Ns<AliasedClass at 0x%x; %s>(tidR�R�R>(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR8
s	cCs
t|j�S(N(tstrR�(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt__str__sN((	R>R?R@R!RMR�R�R8R�(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��s9		R�cBs�eZdZd�ZeZed��Zej	d��Z
d�Zd�Zd�Z
d�Zej	d��Zej	d	��Zd
�Zd�Zd�ZRS(
s�Provide 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||_||_|
|_	|r�t
|_||_g|_
x�|jD]e}||k	r�t|j|d|d|	d|�}t|j|jj|�|j
j|j�q�q�Wnt|_|g|_tj|d|jd|	dt
�|_|	|_|j|_dS(NR�R�R�R�R�(R�R�R�tpersist_selectabletlocal_tableRdR�t_base_aliast_use_mapper_pathR�RUt_is_with_polymorphicR�t_with_polymorphic_entitiesR�R�R�R>RQR�RMRsR�t_equivalent_columnst_adaptert_adapt_on_namesR�(
R6R�R�R�RdR�R�R�R�R�R�tpolytent((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR�8s>
													cCs
|jjS(sUReturn the mapped class ultimately represented by this
        :class:`.AliasedInsp`.(R�R�(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR�rscCs$|jr|jjStj|�SdS(N(R�R�t_path_registryRt
per_mapper(R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR�xs	
cCshi
|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd	6|j	d
6S(NR�R�RmRdR�R�R�R�R�R�(
R�R�R�RdR�R�R�R�R�R�(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(NR�R�RmRdR�R�R�R�R�R�(R�(R6RF((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt__setstate__�scCs*|jj|�ji|d6|jd6�S(NtparententityR�(R�ttraverset	_annotateR�(R6R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_adapt_element�scCsz|j}||krD||jkr(|St|j|jj�jSn2|j|j�rZ|Stsvt	d||f��dS(Ns"mapper %s doesn't correspond to %s(
R�R�R�R�R�R>R�R�RMtAssertionError(R6R�t	self_poly((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_entity_for_mapper�s	cs>�jj\}}�jj|��fd�|j�D�fS(Ncs+i|]!\}}|�jj|��qS((R�R�(t.0Ritparam(R6(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pys
<dictcomp>�s	(R�t_get_clauseR�R�Rp(R6tonclauset
replacemap((R6sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��scCsiS(N((R6((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_memoized_values�scOs<||jkr|j|S|||�|j|<}|SdS(N(R�(R6RHt	callable_R�tkwRN((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_memo�scCsO|jr,ddjd�|jD��}nd}dt|�|jj|fS(Ns(%s)s, css|]}|jjVqdS(N(R�R>(R�tmp((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pys	<genexpr>�sR9s<AliasedInsp at 0x%x; %s%s>(R�R(R�R�R>(R6t	with_poly((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR8�s				csN�jr9d�jjdj�fd��jD��fSd�jjfSdS(Nswith_polymorphic(%s, [%s])s, c3s*|] }|�jk	r|jjVqdS(N(R�R�R>(R�R�(R6(sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pys	<genexpr>�ssaliased(%s)(R�R�R>R(R�(R6((R6sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��s		(R>R?R@R�RUR�tpropertyR�Rtmemoized_propertyR�R�R�R�R�R�R�R�R8R�(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR�s"	7						
cCs|jS(N(R�(R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt<lambda>�R9cCs|S(N((R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��R9c
Csct|tj�r=|r*tjd��n|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 elementsR�RmRdR�N(RRt
FromClauseR&R'RmR�(telementRmRdR�R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytaliased�sPc	
Cs�t|�}	|r}|j|	ks't�tj|�}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 <fromclauses>) 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	innerjoinR�R�R�R�R�(RR�R�Rtto_setR#R�R�tuniont_with_polymorphic_argsRmR�(
tbasetclassesR�R�R�R�R�R�t_existing_aliastprimary_mapperR�tnew_classestmappers((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytwith_polymorphicCs(K"cCstj|itd6|�S(s�Deep 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(R�texclude((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt
_orm_annotate�scCstj|dd�S(s�Remove 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.

    R4R�R�(R�R�(Rst_deep_deannotate(R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_orm_deannotate�s	cCs
tj|�S(N(RsR�(R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_orm_full_deannotate�st_ORMJoincBsbeZdZejjZdeeddd�Zd�Z	deedd�Z
dedd�ZRS(s/Extend Join to support ORM constructs as input.cCs5tj|�}t|d|�}	tj|�}
|
j}|
|_||_||_t|tj	�r{t|	j
|�}nt|tj�r�|j
j�}|j}
n*t|t�r�|}
|
jj}nd}
|
r�tj||j�r�|}n	|j}|
jd|d|dtdtd|
j�\}}}}}}|dk	r�|rntj|||�}|}q�tj||||�}|}n|}||_ntjj||||||�|
r1t|
dd�r1|
jjr1|
jj}|dk	r1|
j r|
j!j"|�}n|j#|@|_#q1ndS(Nt_joined_from_infotsource_selectabletdest_selectabletsource_polymorphictdest_polymorphictof_type_mapperR�($RR�R�R�R�t
_left_memot_right_memoRRR R�RtQueryableAttributet
comparatort_source_selectableR�R
tparentR!Rstclause_is_presentt
_create_joinsRUR�RR(t_target_adapterRtJoinR�tsinglet_single_table_criterionR�R�R�R�(R6tlefttrightR�tisoutertfullRRt	left_infot
left_orm_infot
right_infotadapt_tot
on_selectabletpropt
adapt_fromtpjtsjtsourcetdestt	secondaryttarget_adaptertsingle_crit((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��sV
											c
Cs�|}xt|tj�r'|j}q	W|j|ks=t�t|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
RR�R�R�RRR(R6tothertleftmostR
((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_splice_into_centers"
					cCst|||d|d|�S(NRR(R�(R6RR�RRtjoin_to_left((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR(8scCst|||dtd|�S(NRR(R�RU(R6RR�RR"((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt	outerjoinBsN(R>R?R@RR
t__visit_name__R!RMR�R!R(R#(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR��sJ	 cCst|||||�S(s�Produce 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
RR�RRR"((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.

    (R�RU(R
RR�RR"((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyR#sscCsgt|tj�r6t|�}t|j|�j}nt|tj�rT|j}n|j	|d|�S(s�Create 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

    tfrom_entity(
RRR RR�R�R�RRt_with_parent(R�RR%R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytwith_parent~scCstj|�}|jS(s�Return 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(s�Return 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(twas_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(s�determine 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.

    (R�R�RURMR�R�t
common_parent(tgivenR�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_entity_corresponds_to�s				

cCsh|jr5|jo4|jo4||kp4||jkS|jsN|j|j�S|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(R�R�R�R,R�R�(R-R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt$_entity_corresponds_to_use_path_impl�s		
		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(R�R�R�R�(R-R�((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt_entity_isa�s		
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
unitofworktsessionR�t
dependency(ttopological(t	RandomSetN(
tsqlalchemy.ormR1R2R�R3tsqlalchemy.utilR4tsqlalchemy.testing.utilR5R#(R1R2R�R3R4R5((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pytrandomize_unitofworks"(Rs
delete-orphanRRRssave-updatesrefresh-expireR(=R:RhR9RR�RRRRRRRRR	R
RRt
interfacesR
Rt
path_registryRRRR&RRRRRsR/RARR]RUR}R�R�R�tobjectR�R�t	_inspectsR!RMR�R�R�R�R�R
R�R(R#R'R)R+R.R/R0R9(((sF/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/util.pyt<module>	s~	?	CH	g'��c\
		�,#				#	

Zerion Mini Shell 1.0