Ñò ‰„[Jc@südZddklZlZlZddklZlZddklZddk l Z e Z e Z deifd„ƒYZdefd „ƒYZeieƒd efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdS(sdThe internals for the Unit Of Work system. Includes hooks into the attributes package enabling the routing of change events to Unit Of Work objects, as well as the flush() mechanism which creates a dependency structure that executes change operations. A Unit of Work is essentially a system of maintaining a graph of in-memory objects and their modified state. Objects are maintained as unique against their primary key identity using an *identity map* pattern. The Unit of Work then maintains lists of objects that are new, dirty, or deleted and provides the capability to flush all those changes at once. iÿÿÿÿ(tutiltlogt topological(t attributest interfaces(R(t _state_mappertUOWEventHandlercBs2eZdZd„Zd„Zd„Zd„ZRS(sdAn event handler added to all relation attributes which handles session cascade operations. cCs ||_dS(N(tkey(tselfR((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyt__init__%scCs^t|ƒ}|oGt|ƒi|iƒ}|iio||jo|i|ƒqZn|S(N(t_state_sessionRt get_propertyRtcascadet save_updatetadd(Rtstatetitemt initiatortsesstprop((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytappend(s  cCs}t|ƒ}|oft|ƒi|iƒ}|iio=||ijo-|iit i |ƒƒo|i |ƒqyndS(N( R RR RR t delete_orphantnewtmappert _is_orphanRtinstance_statetexpunge(RRRRRR((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytremove1s  cCsÇ||jo|St|ƒ}|ožt|ƒi|iƒ}|dj o+|iio||jo|i|ƒn|iio=||i jo-|i i t i |ƒƒo|i|ƒqÃn|S(N(R RR RtNoneR R RRRRRRRR(RRtnewvaluetoldvalueRRR((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytset;s  '(t__name__t __module__t__doc__R RRR(((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyR s   tUOWTransactioncBs›eZdZd„Zed„Zeeedd„Zd„Z d„Z ed„Z d„Z d„Z d „Zd „Zed „ƒZd „Zd „ZRS(sgHandles the details of organizing and executing transaction tasks during a UnitOfWork object's flush() operation. The central operation is to form a graph of nodes represented by the ``UOWTask`` class, which is then traversed by a ``UOWExecutor`` object that issues SQL and instance-synchronizing operations via the related packages. cCsC||_|i|_tƒ|_h|_h|_tƒ|_dS(N(tsessiont_mapper_flush_optstmapper_flush_optsRt dependenciesttasksRt processors(RR$((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyR Ts      cCsÎd||f}||ijoU|i|\}}|o7| o/ti||dtƒ}||f|i|%s)iiN(tclass_R (t.0td((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pys .s sDependency sort: (Rtsort_with_cyclesR'R(ReRIRR<t_sort_circular_dependenciesRR7R8R9tjointstr( Rt_[1]tttnodesRaRtcyclesRBt_[2]ti((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyR[s" D 7 N(R R!R"R RWR3R-RRCRGRHR<RPRVR`R^tpropertyRfRjR[(((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyR#Js         RKcBseZdZdd„Zeid„ƒZed„ƒZ d„Z e e d„Z d„Z d„Zd„Zd „Zed „ƒZed „ƒZed „ƒZed „ƒZed„ƒZed„ƒZed„ƒZed„ƒZd„Zd„ZRS(sCA collection of mapped states corresponding to a particular mapper.cCs€||_|djo||_h||6|_n||_||i|<||_h|_g|_tƒ|_tƒ|_ dS(N( tuowtransactionRRIt_inheriting_tasksRREtdependent_tasksRR'tcyclical_dependencies(RRyRRI((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyR 8s         cCst|iiƒƒS(N(RYRtpolymorphic_iterator(R((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytinheriting_mappersRsccsFx?|iD]4}|iii|dƒ}|dj o |Vq q WdS(sìReturn an iterator of UOWTask objects corresponding to the inheritance sequence of this UOWTask's mapper. e.g. if mapper B and mapper C inherit from mapper A, and mapper D inherits from B: mapperA -> mapperB -> mapperD -> mapperC the inheritance sequence starting at mapper A is a depth-first traversal: [mapperA, mapperB, mapperD, mapperC] this method will therefore return [UOWTask(mapperA), UOWTask(mapperB), UOWTask(mapperD), UOWTask(mapperC)] The concept of "polymporphic iteration" is adapted into several property-based iterators which return object instances, UOWTaskElements and UOWDependencyProcessors in an order corresponding to this sequence of parent UOWTasks. This is used to issue operations related to inheritance-chains of mappers in the proper order based on dependencies between those mappers. N(R~RIRztgetR(RRRs((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytpolymorphic_tasksVs   cCs|i o|i S(sxreturn True if this UOWTask is 'empty', meaning it has no child items. used only for debugging output. (RER'(R((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytis_emptyyscCsL||ijot|ƒ|i|<}n|i|}|i||ƒdS(N(REtUOWTaskElementtupdate(RRR4R5trec((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyRs cCs/|ii|g|idtdt|ƒƒdS(s»issue a 'post update' UPDATE statement via this object's mapper immediately. this operation is used only with relations that specify the `post_update=True` flag. R@RAN(Rt _save_objRyRWR(RRRA((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyR=‰s cCs1x*|iD]}||ijotSq WtSdS(sUreturn True if the given object is contained within this UOWTask or inheriting tasks.N(R€RERWR-(RRRB((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyt __contains__•s   cCs-y|i|iSWntj otSXdS(sOreturn True if the given object is marked as to be deleted within this UOWTask.N(RER5RJR-(RR((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyRHžscst‡fd†ƒ}|S(sureturn a property that will adapt the collection returned by the given callable into a polymorphic traversal.c3s4x-|iD]"}xˆ|ƒD] }|VqWq WdS(N(R€(RRBR„(tfn(s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyt collectionªs   (Rx(R‡Rˆ((R‡s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyt_polymorphic_collection¦scCs |iiƒS(N(RERX(R((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyRf±scCs|iS(N(Rf(R((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytpolymorphic_elementsµscCs0g}|iD]}|ip ||qq~S(N(RŠR5(RRrR„((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytpolymorphic_tosave_elements¹scCs0g}|iD]}|io ||qq~S(N(RŠR5(RRrR„((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytpolymorphic_todelete_elements½scCsTg}|iD]?}|idj o)|i o|itjo||iqq~S(N(RŠRRR4R5R-(RRrR„((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytpolymorphic_tosave_objectsÁscCsTg}|iD]?}|idj o)|i o|itjo||iqq~S(N(RŠRRR4R5RW(RRrR„((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytpolymorphic_todelete_objectsÈscCs|iS(N(R'(R((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pytpolymorphic_dependenciesÏscCs|iS(N(R|(R((s=/usr/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.pyt!polymorphic_cyclical_dependenciesÓsc&s h‰‡‡fd†}tˆƒ‰‡‡fd†}h}g}xvˆD]n}xe|iD]Z}||ƒp|i|ƒnx3|iiD]%} |i| gƒ} | i|ƒqŠWqYWqIWh} g} xúˆD]ò}xé|iD]Þ} xÕ| iD]Ê}|i}| | |<| |joqînxš|| D]Ž}|ii p||ƒ oq&n|i|i}}|i }|i |ˆdt ƒ\}}}| o| o| oq&nˆi |iƒ}|||}xç|D]ß}|djoqÑn||jo!|i|dt ƒ|| |s*é ÿ+O