mò #&ÜGc@sÅdklZlZlZdklZlZdklZ dkl Z dk Z dkZde fd„ƒYZde fd„ƒYZeiZe iƒZd „Zee_d klZee_dS( (sutils exceptionsssql(s unitofworksquery(s object_mapper(s class_mapperNtSessionTransactioncBs_tZdZeed„Zed„Zd„Zd„Zd„Z d„Z d„Z d„Z RS( sñrepresents a Session-level Transaction. This corresponds to one or more sqlalchemy.engine.Transaction instances behind the scenes, with one Transaction per Engine in use. the SessionTransaction object is **not** threadsafe.cCs(||_h|_||_||_dS(N(tsessiontselft connectionstparentt autoflush(RRRR((t:/home/holguin2/public_html/spyce/sqlalchemy/orm/session.pyt__init__s   cCsit|tƒot|d|ƒ}n|idj o|ii|ƒSn|i i |ƒ}|i |ƒS(Nt entity_name( t isinstancetmapper_or_classttypet _class_mapperRRRtNonet connectionRtget_bindtenginet get_or_add(RR RR((RRs cCst|i|ƒS(N(RRR(R((Rt_begin!scCs6|ii|iƒotidƒ‚n|i|ƒS(NsMSession already has a Connection associated for the given Connection's Engine(RRthas_keyt connectableRt exceptionstInvalidRequestErrorR(RR((Rtadd#scCs‰|ii|iƒo|i|idSn|i}|iƒ}|ii|ƒp&||iƒ||j f|i||idj o|iiƒSnt|||_|iSdS(süreturns a new SessionTransaction corresponding to an existing or new transaction. if the transaction is new, the returned SessionTransaction will have commit control over the underlying transaction, else will have rollback control only.N(RR$R RRtkwargs(RR9((Rtcreate_transactionds cKs|i|ƒi|S(s“returns a unique connection corresponding to the given mapper. this connection will not be part of any pre-existing transactional context.N(RRtmappertconnectR9(RR;R9((RR<mscKs>|idj o|ii|ƒSn|i|ƒi|SdS(sSreturns a Connection corresponding to the given mapper. used by the execute() method which performs select operations for Mapper and Query. if this Session is transactional, the connection will be in the context of this session's transaction. otherwise, the connection is returned by the contextual_connect method, which some Engines override to return a thread-local connection, and will have close_with_result set to True. the given **kwargs will be sent to the engine's contextual_connect() method, if no transaction is in progress.N(RR$R RR;RRR9(RR;R9((RRqscKs"|i|dtƒi|||S(sÍusing the given mapper to identify the appropriate Engine or Connection to be used for statement execution, executes the given ClauseElement using the provided parameter dictionary. Returns a ResultProxy corresponding to the execution's results. If this method allocates a new Connection for the operation, then the ResultProxy's close() method will release the resources of the underlying Connection, otherwise its a no-op. tclose_with_resultN(RRR;R(texecutetclausetparamsR9(RR;R?R@R9((RR>~scKs"|i|dtƒi|||S(s1works like execute() but returns a scalar result.R=N(RRR;R(tscalarR?R@R9(RR;R?R@R9((RRA…scCs/|iƒ|idj o|iiƒndS(scloses this Session. N(RtclearR$R R (R((RR ‰s cCsIx|D]}|i|ƒqW|ii}tiƒ|_||i_dS(sremoves all object instances from this Session. this is equivalent to calling expunge() for all objects in this Session.N(Rtinstancet _unattachR.R5R,R-(RRCR5((RRBs cCst|d|ƒS(sGgiven an Class, return the primary Mapper responsible for persisting itRN(R tclass_R(RRER((RR;™scCs||i|"sN(Rt _save_implRURRntcascade_callable(RRUR((RRtsaves cs6ˆi|d|ƒt|ƒid|‡d†ƒdS(scBring the given detached (saved) instance into this Session. If there is a persistent instance with the same identifier already associated with this Session, an exception is thrown. This operation cascades the "save_or_update" method to associated instances if the relation is mapped with cascade="save-update".Rs save-updatecsˆi||ƒS(N(RRqRR(RR(R(RRr-sN(Rt _update_implRURRnRt(RRUR((RRtupdate$scs6ˆi|d|ƒt|ƒid|‡d†ƒdS(s¿save or update the given object into this Session. The presence of an '_instance_key' attribute on the instance determines whether to save() or update() the instance.Rs save-updatecsˆi||ƒS(N(RRqRR(RR(R(RRr5sN(RRqRURRnRt(RRUR((RRtsave_or_update/scCsMt|ddƒ}|djo|i|d|ƒn|i|d|ƒdS(NR`R(RORUR RQRRsRRv(RRURRQ((RRq7s cCsDx=|gtt|ƒid|ƒƒD]}|ii|ƒq&WdS(s^mark the given instance as deleted. the delete operation occurs upon flush().tdeleteN(RURmRnRoRRR.tregister_deleted(RRURR((RRy>s&c Csd}x|gtt|ƒid|ƒƒD]ë}t|ddƒ}|djoit|ƒ}|i |ƒ}x8|D]0} | djot idt|ƒƒ‚qsqsW|i|ƒ}n|i}|ii|ƒo|i|} n|i|i|dƒ} ||jo | }q,q,W|S(s˜merge the object into a newly loaded or existing instance from this Session. note: this method is currently not completely implemented.tmergeR`s±Instance '%s' does not have a full set of identity values, and does not represent a saved entity in the database. Use the add() method to add unsaved instances to this Session.iN(R RCRURmRnRoR]RORQR;tidentityRYR#RRRat identity_keyRR.tuR*RtinstRXR^( RRURR;RYR]RCR~RQRR#((RR{Es(&   !  cKs†t|dƒo7|ii|iƒptidt|ƒƒ‚q‚n<t |i d|i ddƒƒ}|i|ƒ|i|ƒdS(NR`sTInstance '%s' is a detached instance or is already persistent in a different SessionR(thasattrRURR*RR`RRRaR R^R9RXR tmt_assign_entity_namet_register_pending(RRUR9R((RRs^s !! cKsf|i|ƒo||ijodSnt|dƒptidt|ƒƒ‚n|i|ƒdS(NR`sInstance '%s' is not persisted( Rt _is_attachedRUtdeletedR€RRRat_register_persistent(RRUR9((RRvms  cCs!|i|ƒ|ii|ƒdS(N(Rt_attachR]R.t register_new(RR]((RRƒts cCs!|i|ƒ|ii|ƒdS(N(RR‡R]R.tregister_clean(RR]((RR†ws cCs!|i|ƒ|ii|ƒdS(N(RR‡R]R.Rz(RR]((Rt_register_deletedzs cCs»t|ddƒ|ijo›t|ddƒ}|dj o<ti|ƒo,ti dt |ƒ|t |ƒfƒ‚nt|ddƒ}|dj o||i |Object '%s' is already attached to session '%s' (this is '%s')R`N(ROR]R RR2toldR4RRRRaR3RQR*R‹(RR]RŒRQ((RR‡~s,  cCs|i|ƒ|`dS(N(Rt_validate_attachedR]R‹(RR]((RRD“s cCs1|i|ƒptidt|ƒƒ‚ndS(sSvalidate that the given object is either pending or persistent within this Session.s*Instance '%s' not attached to this SessionN(RR„R]RRRa(RR]((RR—scCs|ii|ƒdS(sAvalidate that the given object is persistent within this Session.N(RR.t _validate_objR](RR]((RR\›scCst|ddƒ|ijS(NR‹(ROR]R RR2(RR]((RR„žscCs6|i|ƒo&||iijp|ii|iƒS(N(RR„R]R.tnewR*RR`(RR]((Rt __contains__ scCs&tt|iiƒ|iiiƒƒS(N(titerRmRR.RR*R(R((Rt__iter__¢scCs |i|S(N(RR*RQ(RRQ((RR_¤scCs|ii|ƒS(N(RR*RRQ(RRQ((RR¦scCs |iiƒS(N(tsR.t locate_dirty(R“((RRr©stdocs:a Set of all objects marked as 'dirty' within this SessioncCs |iiS(N(R“R.R…(R“((RRrªss<a Set of all objects marked as 'deleted' within this SessioncCs |iiS(N(R“R.R(R“((RRr«ss9a Set of all objects marked as 'new' within this Session.cCs |iiS(N(R“R.R*(R“((RRr¬ssga WeakValueDictionary consisting of all objects within this Session keyed to their _instance_key value.cOs|i||ŽS(s!deprecated; a synynom for merge()N(RR{RRR9(RRRR9((Rtimport_instance®s(8R%R&R'R tFalseRR6R8tpropertyR1R:R<RR>RAR RBR;RGRIRRLRVRPRRXRZRbRfRkRlRuRwRxRqRyR{RsRvRƒR†RŠR‡RDRR\R„RR’R_RtdirtyR…RR*R–(((RR)Isf           !                        cCs4t|ddƒ}|dj oti|ƒSndS(sGreturn the Session to which the given object is bound, or None if none.R‹N(ROR]R thashkeyR4RX(R]Rš((Rtobject_session½s  (smapper(t sqlalchemytutilRRPtsqlalchemy.ormR,RLtsqlalchemy.orm.mappert object_mapperRnt class_mapperR tweakrefRURR)RdtWeakValueDictionaryR4R›R;(R¢R›RœR;RnRRR R)R,R4RPRRLRd((Rt?s    :ÿm