Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / sqlalchemy / orm / interfaces.pyc
Size: Mime:
ó
‹EYc@@s4dZddlmZddlmZddlmZddlmZm	Z	m
Z
mZmZm
Z
ddlmZmZmZmZdd	lZdd
lmZd	ZZZdZdeeejfd„ƒYZdejfd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZd	S(sI

Contains various base classes used throughout the ORM.

Defines some key base classes prominent within the internals,
as well as the now-deprecated ORM extension classes.

Other than the deprecated extensions, this module and the
classes within are mostly private, though some attributes
are exposed when inspecting mappings.

i(tabsolute_importi(tutil(t	operatorsi(t	ONETOMANYt	MANYTOONEt
MANYTOMANYtEXT_CONTINUEtEXT_STOPt
NOT_EXTENSION(tInspectionAttrR	tInspectionAttrInfot_MappedAttributeN(tinspecttAttributeExtensionRRRRRRtLoaderStrategytMapperExtensiontMapperOptiontMapperPropertytPropComparatortSessionExtensiontStrategizedPropertycB@s¤eZdZdZeƒZeZd„Zd„Z	d„Z
ddd	„Zd
„Z
d„Zd„Zd
„Zed„ƒZd„Zd„Zd„Zd„ZRS(s™Represent a particular class attribute mapped by :class:`.Mapper`.

    The most common occurrences of :class:`.MapperProperty` are the
    mapped :class:`.Column`, which is represented in a mapping as
    an instance of :class:`.ColumnProperty`,
    and a reference to another class produced by :func:`.relationship`,
    represented in the mapping as an instance of
    :class:`.RelationshipProperty`.

    t_configure_startedt_configure_finishedtparenttkeytinfocC@siS(sRInfo dictionary associated with the object, allowing user-defined
        data to be associated with this :class:`.InspectionAttr`.

        The dictionary is generated when first accessed.  Alternatively,
        it can be specified as a constructor argument to the
        :func:`.column_property`, :func:`.relationship`, or :func:`.composite`
        functions.

        .. versionadded:: 0.8  Added support for .info to all
           :class:`.MapperProperty` subclasses.

        .. versionchanged:: 1.0.0 :attr:`.MapperProperty.info` is also
           available on extension types via the
           :attr:`.InspectionAttrInfo.info` attribute, so that it can apply
           to a wider variety of ORM and extension constructs.

        .. seealso::

            :attr:`.QueryableAttribute.info`

            :attr:`.SchemaItem.info`

        ((tself((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt_memoized_attr_infoUscK@sdS(sCalled by Query for the purposes of constructing a SQL statement.

        Each MapperProperty associated with the target mapper processes the
        statement referenced by the query context, adding columns and/or
        criterion as appropriate.

        N((Rtcontexttentitytpathtadaptertkwargs((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytsetuposcC@sdS(scProduce row processing functions and append to the given
        set of populators lists.

        N((RRRtmappertresultRt
populators((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytcreate_row_processorxscC@s
tdƒS(sžIterate through instances related to the given instance for
        a particular 'cascade', starting with this MapperProperty.

        Return an iterator3-tuples (instance, mapper, state).

        Note that the 'cascade' collection on this MapperProperty is
        checked first for the given type before cascade_iterator is called.

        This method typically only applies to RelationshipProperty.

        ((titer(Rttype_tstatetvisited_instancesthalt_on((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytcascade_iteratorscC@s
||_dS(s¹Set the parent mapper that references this MapperProperty.

        This method is overridden by some subclasses to perform extra
        setup when the mapper is first known.

        N(R(RRtinit((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt
set_parentscC@sdS(sIHook called by the Mapper to the property to initiate
        instrumentation of the class attribute managed by this
        MapperProperty.

        The MapperProperty here will typically call out to the
        attributes module to set up an InstrumentedAttribute.

        This step is the first of two steps to set up an InstrumentedAttribute,
        and is called early in the mapper setup process.

        The second step is typically the init_class_attribute step,
        called from StrategizedProperty via the post_instrument_class()
        hook.  This step assigns additional state to the InstrumentedAttribute
        (specifically the "impl") which has been determined after the
        MapperProperty has determined what kind of persistence
        management it needs to do (e.g. scalar, object, collection, etc).

        N((RR"((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytinstrument_class˜scC@st|_t|_dS(N(tFalseRR(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt__init__¬s	cC@s t|_|jƒt|_dS(s¥Called after all mappers are created to assemble
        relationships between mappers and perform other post-mapper-creation
        initialization steps.

        N(tTrueRtdo_initR(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR,°s	
cC@st|jj|jƒS(s®Return the class-bound descriptor corresponding to this
        :class:`.MapperProperty`.

        This is basically a ``getattr()`` call::

            return getattr(self.parent.class_, self.key)

        I.e. if this :class:`.MapperProperty` were named ``addresses``,
        and the class to which it is mapped is ``User``, this sequence
        is possible::

            >>> from sqlalchemy import inspect
            >>> mapper = inspect(User)
            >>> addresses_property = mapper.attrs.addresses
            >>> addresses_property.class_attribute is User.addresses
            True
            >>> User.addresses.property is addresses_property
            True


        (tgetattrRtclass_R(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytclass_attributeºscC@sdS(sºPerform subclass-specific initialization post-mapper-creation
        steps.

        This is a template method called by the ``MapperProperty``
        object's init() method.

        N((R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR2ÔscC@sdS(sPerform instrumentation adjustments that need to occur
        after init() has completed.

        The given Mapper is the Mapper invoking the operation, which
        may not be the same Mapper as self.parent in an inheritance
        scenario; however, Mapper will always at least be a sub-mapper of
        self.parent.

        This method is typically used by StrategizedProperty, which delegates
        it to LoaderStrategy.init_class_attribute() to perform final setup
        on the class-bound InstrumentedAttribute.

        N((RR"((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytpost_instrument_classÝscC@sdS(soMerge the attribute represented by this ``MapperProperty``
        from source to destination object.

        N((Rtsessiontsource_statetsource_dictt
dest_statet	dest_dicttloadt
_recursive((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytmergeìscC@s)d|jjt|ƒt|ddƒfS(Ns<%s at 0x%x; %s>Rsno key(t	__class__t__name__tidR3(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt__repr__ós	(s_configure_starteds_configure_finishedsparentskeysinfoN(R@t
__module__t__doc__t	__slots__t	frozensettcascadeR1tis_propertyRR!R%tNoneR+R-R.R0R,tpropertyR5R2R6R>RB(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR5s&
											
				cB@s¶eZdZdZdd„Zd„Zd„Zd„Ze	d	„ƒZ
e	d
„ƒZe	d„ƒZe
d„ƒZe
d
„ƒZe
d„ƒZd„Zdd„Zdd„ZRS(s:
Defines SQL operators for :class:`.MapperProperty` objects.

    SQLAlchemy allows for operators to
    be redefined at both the Core and ORM level.  :class:`.PropComparator`
    is the base class of operator redefinition for ORM-level operations,
    including those of :class:`.ColumnProperty`,
    :class:`.RelationshipProperty`, and :class:`.CompositeProperty`.

    .. note:: With the advent of Hybrid properties introduced in SQLAlchemy
       0.7, as well as Core-level operator redefinition in
       SQLAlchemy 0.8, the use case for user-defined :class:`.PropComparator`
       instances is extremely rare.  See :ref:`hybrids_toplevel` as well
       as :ref:`types_operators`.

    User-defined subclasses of :class:`.PropComparator` may be created. The
    built-in Python comparison and math operator methods, such as
    :meth:`.operators.ColumnOperators.__eq__`,
    :meth:`.operators.ColumnOperators.__lt__`, and
    :meth:`.operators.ColumnOperators.__add__`, can be overridden to provide
    new operator behavior. The custom :class:`.PropComparator` is passed to
    the :class:`.MapperProperty` instance via the ``comparator_factory``
    argument. In each case,
    the appropriate subclass of :class:`.PropComparator` should be used::

        # definition of custom PropComparator subclasses

        from sqlalchemy.orm.properties import \
                                ColumnProperty,\
                                CompositeProperty,\
                                RelationshipProperty

        class MyColumnComparator(ColumnProperty.Comparator):
            def __eq__(self, other):
                return self.__clause_element__() == other

        class MyRelationshipComparator(RelationshipProperty.Comparator):
            def any(self, expression):
                "define the 'any' operation"
                # ...

        class MyCompositeComparator(CompositeProperty.Comparator):
            def __gt__(self, other):
                "redefine the 'greater than' operation"

                return sql.and_(*[a>b for a, b in
                                  zip(self.__clause_element__().clauses,
                                      other.__composite_values__())])


        # application of custom PropComparator subclasses

        from sqlalchemy.orm import column_property, relationship, composite
        from sqlalchemy import Column, String

        class SomeMappedClass(Base):
            some_column = column_property(Column("some_column", String),
                                comparator_factory=MyColumnComparator)

            some_relationship = relationship(SomeOtherClass,
                                comparator_factory=MyRelationshipComparator)

            some_composite = composite(
                    Column("a", String), Column("b", String),
                    comparator_factory=MyCompositeComparator
                )

    Note that for column-level operator redefinition, it's usually
    simpler to define the operators at the Core level, using the
    :attr:`.TypeEngine.comparator_factory` attribute.  See
    :ref:`types_operators` for more detail.

    See also:

    :class:`.ColumnProperty.Comparator`

    :class:`.RelationshipProperty.Comparator`

    :class:`.CompositeProperty.Comparator`

    :class:`.ColumnOperators`

    :ref:`types_operators`

    :attr:`.TypeEngine.comparator_factory`

    tpropRJt
_parententityt_adapt_to_entitycC@s,||_|_|p||_||_dS(N(RKRJRLRM(RRKtparentmappertadapt_to_entity((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR0SscC@std|ƒ‚dS(Ns%r(tNotImplementedError(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt__clause_element__XscC@s
|jƒS(N(RQ(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt_query_clause_element[scC@s|j|j|j|ƒS(sŠReturn a copy of this PropComparator which will use the given
        :class:`.AliasedInsp` to produce corresponding expressions.
        (R?RKRL(RRO((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRO^scC@st|jƒjS(sZlegacy; this is renamed to _parententity to be
        compatible with QueryableAttribute.(RRLR"(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt
_parentmapperdscC@s!|jdkrdS|jjSdS(srProduce a callable that adapts column expressions
        to suit an aliased version of this comparator.

        N(RMRIt_adapt_element(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRjscC@s
|jjS(N(RJR(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRuscK@s|j||S(N(tany(tatbR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytany_opyscK@s|j||S(N(thas(RVRWR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pythas_op}scC@s
|j|ƒS(N(tof_type(RVR4((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt
of_type_opscC@s|jtj|ƒS(s”Redefine this object in terms of a polymorphic subclass.

        Returns a new PropComparator from which further criterion can be
        evaluated.

        e.g.::

            query.join(Company.employees.of_type(Engineer)).\
               filter(Engineer.name=='foo')

        :param \class_: a class or mapper indicating that criterion will be
            against this specific subclass.


        (toperateRR\(RR4((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR[…scK@s|jtj||S(sóReturn true if this collection contains any member that meets the
        given criterion.

        The usual implementation of ``any()`` is
        :meth:`.RelationshipProperty.Comparator.any`.

        :param criterion: an optional ClauseElement formulated against the
          member class' table or attributes.

        :param \**kwargs: key/value pairs corresponding to member class
          attribute names which will be compared via equality to the
          corresponding values.

        (R]RRX(Rt	criterionR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRU˜scK@s|jtj||S(sñReturn true if this element references a member which meets the
        given criterion.

        The usual implementation of ``has()`` is
        :meth:`.RelationshipProperty.Comparator.has`.

        :param criterion: an optional ClauseElement formulated against the
          member class' table or attributes.

        :param \**kwargs: key/value pairs corresponding to member class
          attribute names which will be compared via equality to the
          corresponding values.

        (R]RRZ(RR^R ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRYªs(spropspropertys
_parententitys_adapt_to_entityN(R@RCRDRERIR0RQRRRORJRSRRtstaticmethodRXRZR\R[RURY(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRùsV				cB@s†eZdZdZd
Zd„Zd„Zd„Zd„Z	d„Z
d„Zd	„Ze
jeƒZed
„ƒZed„ƒZRS(sŒA MapperProperty which uses selectable strategies to affect
    loading behavior.

    There is a single strategy selected by default.  Alternate
    strategies can be selected at Query time through the usage of
    ``StrategizedOption`` objects via the Query.options() method.

    The mechanics of StrategizedProperty are used for every Query
    invocation for every mapped attribute participating in that Query,
    to determine first how the attribute will be rendered in SQL
    and secondly how the attribute will retrieve a value from a result
    row and apply it to a mapped object.  The routines here are very
    performance-critical.

    t_strategieststrategycC@s_d}tj||ƒ}x@|j|j|jfD]&}||jkr1|j|}Pq1q1W|S(N(RItdictt__getitem__t_loader_keyt_wildcard_path_loader_keyt_default_path_loader_keyt
attributes(RRRR<tsearch_pathtpath_key((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt_get_context_loaderÒs
cC@sYy|j|SWnCtk
rT|j|Œ}||ƒ|j|<|j|<}|SXdS(N(R`tKeyErrort_strategy_lookup(RRtclsRa((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt
_get_strategyæs
"cC@s|j|jdƒS(Ni(Rnt_strategy_keys(RRm((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt_get_strategy_by_clsïscK@s_|j||ƒ}|r6|jr6|j|jƒ}n	|j}|j||||||dS(N(RjRaRntsetup_query(RRRRRR tloadertstrat((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR!òs
	c		C@sb|j||ƒ}|r6|jr6|j|jƒ}n	|j}|j|||||||ƒdS(N(RjRaRnR%(	RRRR"R#RR$RrRs((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR%ûs		cC@s"i|_|j|jƒ|_dS(N(R`Rptstrategy_classRa(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR2s	cC@s:|jjr6|jj|jƒr6|jj|ƒndS(N(Rtnon_primaryt
class_managert_attr_has_implRRatinit_class_attribute(RR"((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR6s
c@s‡‡fd†}|S(Nc@sXd|jkrg|_nttˆjƒƒƒ}|ˆjˆ|<|jj|ƒ|S(NRo(t__dict__Rottupletsortedtitemst_all_strategiestappend(tdec_clsR(Rmtkw(sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytdecorates((RmR€R((RmR€sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytstrategy_fors	cG@smxP|jD]E}||jkr
|j|}y||SWqOtk
rKqOXq
q
Wtd||fƒ‚dS(Nscan't locate strategy for %s %s(t__mro__R}Rkt	Exception(RmRtprop_clst
strategies((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRls

(s_strategiessstrategyN(R@RCRDRERItstrategy_wildcard_keyRjRnRpR!R%R2R6tcollectionstdefaultdictRbR}tclassmethodR‚Rl(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR½s									
cB@s&eZdZeZd„Zd„ZRS(s#Describe a modification to a Query.cC@sdS(s2Apply a modification to the given :class:`.Query`.N((Rtquery((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt
process_query5scC@s|j|ƒdS(slsame as process_query(), except that this option may not
        apply to the given query.

        This is typically used during a lazy load or scalar refresh
        operation to propagate options stated in the original Query to the
        new Query being used for the load.  It occurs for those options that
        specify propagate_to_loaders=True.

        N(RŒ(RR‹((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pytprocess_query_conditionally8s(R@RCRDR/tpropagate_to_loadersRŒR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR+s	cB@sAeZdZd
Zd„Zd„Zd„Zd„Zd	„ZRS(sÈDescribe the loading behavior of a StrategizedProperty object.

    The ``LoaderStrategy`` interacts with the querying process in three
    ways:

    * it controls the configuration of the ``InstrumentedAttribute``
      placed on a class to handle the behavior of the attribute.  this
      may involve setting up class-level callable functions to fire
      off a select operation when the attribute is first accessed
      (i.e. a lazy load)

    * it processes the ``QueryContext`` at statement construction time,
      where it can modify the SQL statement that is being produced.
      For example, simple column attributes will add their represented
      column to the list of selected columns, a joined eager loader
      may establish join clauses to add to the statement.

    * It produces "row processor" functions at result fetching time.
      These "row processor" functions populate a particular attribute
      on a particular mapped instance.

    tparent_propertytis_class_levelRRcC@s4||_t|_|jj|_|jj|_dS(N(RR/RRR(RR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR0`s		cC@sdS(N((RR"((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRxfscK@sdS(sïEstablish column and other state for a given QueryContext.

        This method fulfills the contract specified by MapperProperty.setup().

        StrategizedProperty delegates its setup() method
        directly to this method.

        N((RRRRtloadoptRR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRqiscC@sdS(sEstablish row processing functions for a given QueryContext.

        This method fulfills the contract specified by
        MapperProperty.create_row_processor().

        StrategizedProperty delegates its create_row_processor() method
        directly to this method.

        N((RRRR‘R"R#RR$((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyR%sscC@s
t|jƒS(N(tstrR(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt__str__s(sparent_propertysis_class_levelsparentskey(	R@RCRDRER0RxRqR%R“(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyRFs			
	(sAttributeExtensionsEXT_CONTINUEsEXT_STOPs	ONETOMANYs
MANYTOMANYs	MANYTOONEs
NOT_EXTENSIONsLoaderStrategysMapperExtensionsMapperOptionsMapperPropertysPropComparatorsSessionExtensionsStrategizedProperty( RDt
__future__RtRtsqlRtbaseRRRRRRR	R
RRˆRRIRRR
t__all__t
MemoizedSlotsRtColumnOperatorsRRtobjectRR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.pyt<module>s6."ÄÄn