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    
Size: Mime:
ó
‹EYc@sÛdZddlZddlmZddlmZmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZdd	lm	Z	d
ejfd„ƒYZdefd
„ƒYZdefd„ƒYZdS(sŸDefines instrumentation of instances.

This module is usually not directly visible to user applications, but
defines a large part of the ORM's interactivity.

iÿÿÿÿNi(tutili(texct
interfaces(tPathRegistry(tPASSIVE_NO_RESULTtSQL_OKt	NEVER_SETtATTR_WAS_SETtNO_VALUEtPASSIVE_NO_INITIALIZEtINIT_OKtPASSIVE_OFF(tbaset
InstanceStatecBs{eZdZd*Zd*Zd*ZejZ	d+Z
d*Zd*Ze
Ze
Ze
Ze
ZeZd,Zd„Zd*Zejd„ƒZed„ƒZed„ƒZed„ƒZed„ƒZeejdƒd„ƒƒZeejdƒd	„ƒƒZ ed
„ƒZ!ed„ƒZ"ed„ƒZ#ejd
„ƒZ$ejd„ƒZ%ejd„ƒZ&ed„ƒZ'd„Z(d„Z)d„Z*d„Z+ed„ƒZ,d„Z-d„Z.d„Z/d„Z0d„Z1d„Z2d„Z3e4d„ƒZ5d„Z6d„Z7d „Z8ed!„ƒZ9d"„Z:ed#„ƒZ;ed$„ƒZ<d%„Z=e
e
d&„Z>d'„Z?d*d(„Z@e4d*d)„ƒZARS(-s‰tracks state information at the instance level.

    The :class:`.InstanceState` is a key object used by the
    SQLAlchemy ORM in order to track the state of an object;
    it is created the moment an object is instantiated, typically
    as a result of :term:`instrumentation` which SQLAlchemy applies
    to the ``__init__()`` method of the class.

    :class:`.InstanceState` is also a semi-public object,
    available for runtime inspection as to the state of a
    mapped instance, including information such as its current
    status within a particular :class:`.Session` and details
    about data on individual attributes.  The public API
    in order to acquire a :class:`.InstanceState` object
    is to use the :func:`.inspect` system::

        >>> from sqlalchemy import inspect
        >>> insp = inspect(some_mapped_object)

    .. seealso::

        :ref:`core_inspection_toplevel`

    cCsF|j|_||_tj||jƒ|_i|_tƒ|_	dS(N(
t	__class__tclass_tmanagertweakreftreft_cleanuptobjtcommitted_statetsettexpired_attributes(tselfRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt__init__Ks
		cs&tjt‡fd†ˆjDƒƒƒS(saReturn a namespace representing each attribute on
        the mapped object, including its current value
        and history.

        The returned object is an instance of :class:`.AttributeState`.
        This object allows inspection of the current data
        within an attribute as well as attribute history
        since the last flush.

        c3s$|]}|tˆ|ƒfVqdS(N(tAttributeState(t.0tkey(R(sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pys	<genexpr>is(RtImmutablePropertiestdictR(R((RsI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytattrs[scCs|jdko|jS(syReturn true if the object is :term:`transient`.

        .. seealso::

            :ref:`session_object_states`

        N(RtNonet	_attached(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt	transientns	cCs|jdko|jS(sxReturn true if the object is :term:`pending`.


        .. seealso::

            :ref:`session_object_states`

        N(RR R!(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytpendingzs
cCs|jdk	o|jS(s~Return true if the object is :term:`persistent`.

        .. seealso::

            :ref:`session_object_states`

            N(RR R!(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt
persistent‡s	cCs|jdk	o|jS(sxReturn true if the object is :term:`detached`.

        .. seealso::

            :ref:`session_object_states`

        N(RR R!(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytdetached“s	ssqlalchemy.orm.sessioncCs|jdk	o|j|jkS(N(t
session_idR t	_sessions(Rt
sessionlib((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyR!ŸscCs
|j|ƒS(sReturn the owning :class:`.Session` for this instance,
        or ``None`` if none available.

        Note that the result here can in some cases be *different*
        from that of ``obj in session``; an object that's been deleted
        will report as not ``in session``, however if the transaction is
        still in progress, this attribute will still refer to that session.
        Only when the transaction is completed does the object become
        fully detached under normal circumstances.

        (t_state_session(RR(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytsession¥scCs
|jƒS(sMReturn the mapped object represented by this
        :class:`.InstanceState`.(R(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytobjectµscCs"|jdkrdS|jdSdS(sæReturn the mapped identity of the mapped object.
        This is the primary key identity as persisted by the ORM
        which can always be passed directly to
        :meth:`.Query.get`.

        Returns ``None`` if the object has no primary key identity.

        .. note::
            An object which is :term:`transient` or :term:`pending`
            does **not** have a mapped identity until it is flushed,
            even if its attributes include primary key values.

        iN(RR (R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytidentity»scCs|jS(sõReturn the identity key for the mapped object.

        This is the key used to locate the object within
        the :attr:`.Session.identity_map` mapping.   It contains
        the identity as returned by :attr:`.identity` within it.


        (R(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytidentity_keyÏscCsiS(N((R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytparentsÝscCsiS(N((R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_pending_mutationsáscCs
|jjS(s8Return the :class:`.Mapper` used for this mapepd object.(Rtmapper(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyR0åscCs
t|jƒS(s¯Return ``True`` if this object has an identity key.

        This should always have the same value as the
        expression ``state.persistent or state.detached``.

        (tboolR(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pythas_identityêscCsd|_|_dS(N(R R&t_strong_obj(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_detachôscCs|jƒ|`dS(N(R4R(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_dispose÷s
cCsH|jƒ}|dk	r.|j|ƒ|`nd|_|_|`dS(säWeakref callback cleanup.

        This callable cleans out the state when it is being garbage
        collected.

        this _cleanup **assumes** that there are no strong refs to us!
        Will not work otherwise!

        N(t_instance_dictR t
_fast_discardR&R3R(RRt
instance_dict((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRûs

	cCsdS(N(R (R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRscCs-|jƒ}|dk	r%tj|ƒSiSdS(sReturn the instance dict used by the object.

        Under normal circumstances, this is always synonymous
        with the ``__dict__`` attribute of the mapped object,
        unless an alternative instrumentation system has been
        configured.

        In the case that the actual object has been garbage
        collected, this accessor returns a blank dictionary.

        N(RR RR8(Rto((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRs

cOsŽ|d|d|d}}}|j}|jj|||ƒy|j|d|ŽSWn0tjƒ|jj|||ƒWdQXnXdS(Niii(Rtdispatchtinitt
original_initRtsafe_reraisetinit_failure(tmixedtkwargsRtinstancetargsR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_initialize_instance(s 	
cCs |j|jj||j|ƒS(N(Rtimpltget_historyR(RRtpassive((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRE4scCs|j|jS(N(RRD(RR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytget_impl7scCs-||jkr"tƒ|j|<n|j|S(N(R/tPendingCollection(RR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_get_pending_mutation:scsliˆjƒd6}|j‡fd†dDƒƒˆjrOˆjjƒ|d
<nˆjjˆ|ƒ|d<|S(NRAc3s1|]'}|ˆjkr|ˆj|fVqdS(N(t__dict__(Rtk(R(sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pys	<genexpr>BsRR/tmodifiedtexpiredt	callablesRR.tload_optionsRRt	load_pathR(
scommitted_states_pending_mutationssmodifiedsexpireds	callablesskeysparentssload_optionssclass_sexpired_attributes(RtupdateRPt	serializeRt
_serialize(Rt
state_dict((RsI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt__getstate__?s	cCsÉ|d}|dk	r=tj||jƒ|_|j|_nd|_|d|_|jdiƒ|_|jdiƒ|_	|jdiƒ|_
|jdtƒ|_|jdtƒ|_
d|krØ|d|_ny|d	|_Wngtk
rRtƒ|_xKt|jƒD]6}|j||kr|jj|ƒ|j|=qqWnX|jjgdD]"}||krc|||f^qcƒd|kr±tj|dƒ|_n|d
|||ƒdS(NRARRR/R.RLRMRNRRRORPR(skeysload_options(R RRRRRRtgetRR/R.tFalseRLRMRNRtKeyErrorRtlisttaddRJRQRtdeserializeRP(RRTtinstRK((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt__setstate__Os:
	

	
#cCs~|j|dƒ}|dk	rK|j|jjrK|j|jj|ƒn|jj|ƒ|jrz|jj|dƒndS(sKRemove the given attribute and any
           callables associated with it.N(	tpopR RRDt
collectiont_invalidate_collectionRtdiscardRN(Rtdict_Rtold((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_resetys	csD|ˆj‰ˆjr.‡‡‡fd†}n‡‡fd†}|S(NcsZd|jkri|_n|jˆdƒ}|dk	rIˆj|ƒnˆ|jˆ<dS(NRN(RJRNR^R R`(tstateRbtrowRc(tfnRDR(sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt
_set_callableˆscs,d|jkri|_nˆ|jˆ<dS(NRN(RJRN(ReRbRf(RgR(sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRhs(RDR_(tclsRRgRRh((RgRDRsI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt"_instance_level_callable_processor„s

	cCsot|_|jr8|j|ƒ|jjƒt|_nd|_d|j	kr]|j	d=nd|j	kry|j	d=n|j
jg|jj
D]'}|js­|j|kr|j^qƒ|jróx*|j
j|jƒD]}|j|=qÜWnx8|jjj|ƒD]!}|j|ƒ}t|j_q	Wx$|jjj|ƒD]
}||=qDW|jjj|dƒdS(NR/R.(tTrueRMRLRaRtclearRWR R3RJRRQRt_scalar_loader_implstexpire_missingRRNtintersectiont_collection_impl_keysR^t_sa_adaptertinvalidatedt_all_key_setR:texpire(RRbtmodified_setRDRKR_R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_expire–s,		

	

	(	cCsô|jjddƒ}|j}x¹|D]±}|j|j}|jrs|jj|ƒ|rs||krs||=qsn|j	|dƒ}|j
rª|dk	rª|j|ƒn|jj	|dƒ|r%|j	|dƒq%q%W|jj
j||ƒdS(NR/(RJRVR RNRRDtaccepts_scalar_loaderRRZR^R_R`RR:Rt(RRbtattribute_namesR#RNRRDRc((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_expire_attributes¸s	
	
cCsG|t@stS|jj|jƒ}|jj||ƒ|jjƒtS(s¡__call__ allows the InstanceState to act as a deferred
        callable for loading expired attributes, which is also
        serializable (picklable).

        (	RRRRot
unmodifiedRtdeferred_scalar_loaderRlR(RReRFttoload((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt
_load_expiredÍs
	
cCst|jƒj|jƒS(s8Return the set of keys which have no uncommitted changes(RRt
differenceR(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRzäscCs"t|ƒj|jƒj|jƒS(s*Return self.unmodified.intersection(keys).(RRoRR~R(Rtkeys((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytunmodified_intersectionêscCs%t|jƒj|jƒj|jƒS(s²Return the set of keys which do not have a loaded value.

        This includes expired attributes and any other attribute that
        was never populated or modified.

        (RRR~RR(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytunloadedðscs#ˆjj‡fd†ˆjDƒƒS(Nc3s(|]}ˆj|jjr|VqdS(N(RRDRw(Rtattr(R(sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pys	<genexpr>ÿs(RRoR(R((RsI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_unloaded_non_objectüs	cCsdS(N(R (R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyR6scCsI|js
dS|j|jks%|r–|rƒ|tkrY|j|krY||j}qYn|dttfkrƒ|j|ƒ}qƒn||j|j<n|jr®|jdks¸|j	rEt
|_	|jƒ}|ræ|jj
|ƒn|jƒ}|jr||_n|dkrEtjd|j|jtj|ƒfƒ‚qEndS(NsaCan't emit change event for attribute '%s' - parent object of type %s has been garbage collected.(tsend_modified_eventsRRRR RtcopyR&R3RLRkR6t	_modifiedRZRtorm_exctObjectDereferencedErrorRRtstate_class_str(RRbR‚tpreviousR_tforceR8R\((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_modified_events0	
		
cCs’x!|D]}|jj|dƒqWt|_|jjt|ƒj|ƒƒ|j	rŽx6t|j	ƒj|ƒj|ƒD]}|j	|=qwWndS(s8Commit attributes.

        This is used by a partial-attribute load operation to mark committed
        those attributes which were refreshed from the database.

        Attributes marked as "expired" can potentially remain "expired" after
        this step if a value was not populated in state.dict.

        N(
RR^R RWRMRtdifference_updateRRoRN(RRbRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_commit/s

				
cCs|j||fg|ƒdS(sScommit all attributes unconditionally.

        This is used after a flush() or a full load/refresh
        to remove all pending state from the instance.

         - all attributes are marked as "committed"
         - the "strong dirty reference" is removed
         - the "modified" flag is set to False
         - any "expired" markers for scalar attributes loaded are removed.
         - lazy load callables for objects / collections *stay*

        Attributes marked as "expired" can potentially remain
        "expired" after this step if a value was not populated in state.dict.

        N(t_commit_all_states(RRbR8((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt_commit_allKscCs’x‹|D]ƒ\}}|j}|jjƒd|kr?|d=n|jj|ƒ|rq|jrq|jj|ƒnt|_|_	d|_qWdS(s.Mass / highly inlined version of commit_all().R/N(RJRRlRRRLR†RaRWRMR R3(RtiterR8ReRbRT((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyR]s	

N(((Bt__name__t
__module__t__doc__R R&RtrunidRt	EMPTY_SETRORPtinsert_orderR3RWRLRMtdeletedt
_load_pendingRktis_instanceRNRRtmemoized_propertyRtpropertyR"R#R$R%tdependenciesR!R*R+R,R-R.R/R0R2R4R5RRRRCRERGRIRUR]RdtclassmethodRjRvRyR}RzR€RRƒR6RŒRŽRR(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyR
st			

										*		"				(	RcBsMeZdZd„Zed„ƒZed„ƒZed„ƒZd„ZRS(sŠProvide an inspection interface corresponding
    to a particular attribute on a particular mapped object.

    The :class:`.AttributeState` object is accessed
    via the :attr:`.InstanceState.attrs` collection
    of a particular :class:`.InstanceState`::

        from sqlalchemy import inspect

        insp = inspect(some_mapped_object)
        attr_state = insp.attrs.some_attribute

    cCs||_||_dS(N(ReR(RReR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRs	cCs|jjj|jtƒS(sÇThe current value of this attribute as loaded from the database.

        If the value has not been loaded, or is otherwise not present
        in the object's dictionary, returns NO_VALUE.

        (ReRRVRR(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytloaded_value…scCs,|jj|jj|jjƒ|jjƒS(sàReturn the value of this attribute.

        This operation is equivalent to accessing the object's
        attribute directly or via ``getattr()``, and will fire
        off any pending loader callables if needed.

        (ReRRt__get__RR(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytvalues	cCs|jj|jtƒS(sÇReturn the current pre-flush change history for
        this attribute, via the :class:`.History` interface.

        This method will **not** emit loader callables if the value of the
        attribute is unloaded.

        .. seealso::

            :meth:`.AttributeState.load_history` - retrieve history
            using loader callables if the value is not locally present.

            :func:`.attributes.get_history` - underlying function

        (ReRERR	(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pythistory›scCs|jj|jttAƒS(s„Return the current pre-flush change history for
        this attribute, via the :class:`.History` interface.

        This method **will** emit loader callables if the value of the
        attribute is unloaded.

        .. seealso::

            :attr:`.AttributeState.history`

            :func:`.attributes.get_history` - underlying function

        .. versionadded:: 0.9.0

        (ReRERRR
(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytload_history®s(	R’R“R”RRœRŸR¡R¢R£(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRrs
	
RHcBs)eZdZd„Zd„Zd„ZRS(sA writable placeholder for an unloaded collection.

    Stores items appended to and removed from a collection that has not yet
    been loaded. When the collection is loaded, the changes stored in
    PendingCollection are applied to it to produce the final result.

    cCs"tjƒ|_tjƒ|_dS(N(RtIdentitySett
deleted_itemstOrderedIdentitySettadded_items(R((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRËscCs6||jkr"|jj|ƒn|jj|ƒdS(N(R¥tremoveR§RZ(RR¡((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pytappendÏscCs6||jkr"|jj|ƒn|jj|ƒdS(N(R§R¨R¥RZ(RR¡((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyR¨Õs(R’R“R”RR©R¨(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyRHÂs		(R”RtRRR‡Rt
path_registryRRRRRRRR	R
RtInspectionAttrR
R+RRH(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/orm/state.pyt<module>
s:ÿÿ\P