[Jc@sdZddkZddklZddkiZddklZl Z l Z l Z ddk lZ lZddklZlZlZlZlZlZlZddklZddklZdd klZlZlZdd kl Z dd k!l"Z"dd kl#Z#d ddgZ$e%e%e&e'e&dZ(de)fdYZ*d e)fdYZ+ei,i-Z.ei/Z/ei0Z1dZ2dZ3e'dZ4dZ5dZ6dZ7e6e_6e7e_7ddkl8Z8e.e8_.e7e8_7dS(s1Provides the Session class and related utilities.iN(tchain(tutiltsqltenginetlog(Rt expression(tSessionExtensiont attributestexctqueryt unitofworkRtstate(t object_mapper(t class_mapper(t_class_to_mappert_state_has_identityt _state_mapper(tMapper(tUOWTransaction(tidentitytSessiontSessionTransactionRc sdjo!tidid }n|d<|d<|d<|d<|d jo t}ndtffdYtitd |fh}|S( s!Generate a custom-configured :class:`~sqlalchemy.orm.session.Session` class. The returned object is a subclass of ``Session``, which, when instantiated with no arguments, uses the keyword arguments configured here as its constructor arguments. It is intended that the `sessionmaker()` function be called within the global scope of an application, and the returned class be made available to the rest of the application as the single class used to instantiate sessions. e.g.:: # global scope Session = sessionmaker(autoflush=False) # later, in a local scope, create and use a session: sess = Session() Any keyword arguments sent to the constructor itself will override the "configured" keywords:: Session = sessionmaker() # bind an individual session to a connection sess = Session(bind=connection) The class also includes a special classmethod ``configure()``, which allows additional configurational options to take place after the custom ``Session`` class has been generated. This is useful particularly for defining the specific ``Engine`` (or engines) to which new instances of ``Session`` should be bound:: Session = sessionmaker() Session.configure(bind=create_engine('sqlite:///foo.db')) sess = Session() Options: autocommit Defaults to ``False``. When ``True``, the ``Session`` does not keep a persistent transaction running, and will acquire connections from the engine on an as-needed basis, returning them immediately after their use. Flushes will begin and commit (or possibly rollback) their own transaction if no transaction is present. When using this mode, the `session.begin()` method may be used to begin a transaction explicitly. Leaving it on its default value of ``False`` means that the ``Session`` will acquire a connection and begin a transaction the first time it is used, which it will maintain persistently until ``rollback()``, ``commit()``, or ``close()`` is called. When the transaction is released by any of these methods, the ``Session`` is ready for the next usage, which will again acquire and maintain a new connection/transaction. autoflush When ``True``, all query operations will issue a ``flush()`` call to this ``Session`` before proceeding. This is a convenience feature so that ``flush()`` need not be called repeatedly in order for database queries to retrieve results. It's typical that ``autoflush`` is used in conjunction with ``autocommit=False``. In this scenario, explicit calls to ``flush()`` are rarely needed; you usually only need to call ``commit()`` (which flushes) to finalize changes. bind An optional ``Engine`` or ``Connection`` to which this ``Session`` should be bound. When specified, all SQL operations performed by this session will execute via this connectable. binds An optional dictionary, which contains more granular "bind" information than the ``bind`` parameter provides. This dictionary can map individual ``Table`` instances as well as ``Mapper`` instances to individual ``Engine`` or ``Connection`` objects. Operations which proceed relative to a particular ``Mapper`` will consult this dictionary for the direct ``Mapper`` instance as well as the mapper's ``mapped_table`` attribute in order to locate an connectable to use. The full resolution is described in the ``get_bind()`` method of ``Session``. Usage looks like:: sess = Session(binds={ SomeMappedClass: create_engine('postgres://engine1'), somemapper: create_engine('postgres://engine2'), some_table: create_engine('postgres://engine3'), }) Also see the ``bind_mapper()`` and ``bind_table()`` methods. \class_ Specify an alternate class other than ``sqlalchemy.orm.session.Session`` which should be used by the returned class. This is the only argument that is local to the ``sessionmaker()`` function, and is not sent directly to the constructor for ``Session``. echo_uow Deprecated. Use ``logging.getLogger('sqlalchemy.orm.unitofwork').setLevel(logging.DEBUG)``. _enable_transaction_accounting Defaults to ``True``. A legacy-only flag which when ``False`` disables *all* 0.5-style object accounting on transaction boundaries, including auto-expiry of instances on rollback and commit, maintenance of the "new" and "deleted" lists upon rollback, and autoflush of pending changes upon begin(), all of which are interdependent. expire_on_commit Defaults to ``True``. When ``True``, all instances will be fully expired after each ``commit()``, so that all attribute/object access subsequent to a completed transaction will load from the most recent database state. extension An optional :class:`~sqlalchemy.orm.session.SessionExtension` instance, or a list of such instances, which will receive pre- and post- commit and flush events, as well as a post-rollback event. User- defined code may be placed within these hooks using a user-defined subclass of ``SessionExtension``. query_cls Class which should be used to create new Query objects, as returned by the ``query()`` method. Defaults to :class:`~sqlalchemy.orm.query.Query`. twophase When ``True``, all transactions will be started using :mod:~sqlalchemy.engine_TwoPhaseTransaction. During a ``commit()``, after ``flush()`` has been issued for all attached databases, the ``prepare()`` method on each database's ``TwoPhaseTransaction`` will be called. This allows each database to roll back the entire transaction, before each transaction is committed. weak_identity_map When set to the default value of ``True``, a weak-referencing map is used; instances which are not externally referenced will be garbage collected immediately. For dereferenced instances which have pending changes present, the attribute management system will create a temporary strong-reference to the object which lasts until the changes are flushed to the database, at which point it's again dereferenced. Alternatively, when using the value ``False``, the identity map uses a regular Python dictionary to store instances. The session will maintain all instances present until they are removed using expunge(), clear(), or purge(). t transactionals`The 'transactional' argument to sessionmaker() is deprecated; use autocommit=True|False instead.tbindt autoflusht autocommittexpire_on_committSesscs5eZfdZfdZeeZRS(cs?x"D]}|i||qWt|i|dS(N(t setdefaulttsupert__init__(tselft local_kwargstk(Rtkwargs(s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRscsi|dS(s(Re)configure the arguments for this sessionmaker. e.g.:: Session = sessionmaker() Session.configure(bind=create_engine('sqlite://')) N(tupdate(Rt new_kwargs(R"(s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt configures (t__name__t __module__RR%t classmethod((RR"(s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs RN(Rtwarn_deprecatedtpoptNoneRtobjectttypet__new__(Rtclass_RRRR"ts((RR"s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt sessionmakers       cBseZdZdedZedZdZddZ edZ dZ edZ dd Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZRS(sA Session-level transaction. This corresponds to one or more :class:`~sqlalchemy.engine.Transaction` instances behind the scenes, with one ``Transaction`` per ``Engine`` in use. Direct usage of ``SessionTransaction`` is not necessary as of SQLAlchemy 0.4; use the ``begin()`` and ``commit()`` methods on ``Session`` itself. The ``SessionTransaction`` object is **not** thread-safe. .. index:: single: thread safety; SessionTransaction cCsw||_h|_||_||_t|_t|_| o|oti dn|ii o|i ndS(NsOCan't start a SAVEPOINT transaction when no existing transaction is in progress( tsessiont _connectionst_parenttnestedtTruet_activetFalset _preparedtsa_exctInvalidRequestErrort_enable_transaction_accountingt_take_snapshot(RR2tparentR5((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs        cCs|idj o|iS(N(R2R+R7(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt is_activescCs+|i|iptidndS(NsoThe transaction is inactive due to a rollback in a subtransaction. Issue rollback() to cancel the transaction.(t_assert_is_openR7R:R;(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt_assert_is_actives  sThe transaction is closedcCs'|idjoti|ndS(N(R2R+R:R;(Rt error_msg((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR@scCs|ip|i S(N(R5R4(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt_is_transaction_boundaryscKs,|i|ii||}|i|S(N(RAR2tget_bindt_connection_for_bind(RtbindkeyR"R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt connections cCs |it|i|d|S(NR5(RARR2(RR5((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt_begins cCsZ|i|jo|fS|idjotid|n|f|ii|SdS(Ns4Transaction %s is not on the active transaction list(R4R+R:R;t_iterate_parents(Rtupto((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRI scCsm|ip#|ii|_|ii|_dS|iip|iinti|_ti|_dS(N( RCR4t_newt_deletedR2t _flushingtflushtweakreftWeakKeyDictionary(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR=s  c Cs|iptx6t|ii|iiD]}|ii|q0W|ii ptx6t|ii|iiD]}|ii|q~Wx3|ii i D]}t |dd|ii qWdS(Nt instance_dict( RCtAssertionErrortsetRLtunionR2t _update_implRKt_expunge_statet identity_mapt all_statest _expire_stateR+(RR0((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt_restore_snapshot"scCsg|ipt|i oG|iio:x7|iiiD]}t|dd|iiq<WndS(NRQ( RCRRR5R2RRWRXRYR+(RR0((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt_remove_snapshot0s cCsV|i||ijo|i|dS|io%|ii|}|ip|SnPt|tio0|}|i|ijoti dqn |i }|i i o |idjo|i}n'|io|i}n |i}||||j f|i|<|i|iZ,eid8e*Z-d?Z.d@Z/edAZ0edWdBZ1edCZ2edDZ3dEZ4dFZ5dGZ6dHZ7dIZ8dJZ9dKZ:dLZ;dMZ<dWdNZ=dWdOZ>eedPZ?e@dQZAe@dRZBe@dSZCe@dTZDe@dUZERS(Xs Manages persistence operations for ORM-mapped objects. The Session is the front end to SQLAlchemy's **Unit of Work** implementation. The concept behind Unit of Work is to track modifications to a field of objects, and then be able to flush those changes to the database in a single operation. SQLAlchemy's unit of work includes these functions: * The ability to track in-memory changes on scalar- and collection-based object attributes, such that database persistence operations can be assembled based on those changes. * The ability to organize individual SQL queries and population of newly generated primary and foreign key-holding attributes during a persist operation such that referential integrity is maintained at all times. * The ability to maintain insert ordering against the order in which new instances were added to the session. * An Identity Map, which is a dictionary keying instances to their unique primary key identity. This ensures that only one copy of a particular entity is ever present within the session, even if repeated load operations for the same entity occur. This allows many parts of an application to get a handle to a particular object without any chance of modifications going to two different places. When dealing with instances of mapped classes, an instance may be *attached* to a particular Session, else it is *unattached* . An instance also may or may not correspond to an actual row in the database. These conditions break up into four distinct states: * *Transient* - an instance that's not in a session, and is not saved to the database; i.e. it has no database identity. The only relationship such an object has to the ORM is that its class has a ``mapper()`` associated with it. * *Pending* - when you ``add()`` a transient instance, it becomes pending. It still wasn't actually flushed to the database yet, but it will be when the next flush occurs. * *Persistent* - An instance which is present in the session and has a record in the database. You get persistent instances by either flushing so that the pending instances become persistent, or by querying the database for existing instances (or moving persistent instances from other sessions into your local session). * *Detached* - an instance which has a record in the database, but is not in any session. Theres nothing wrong with this, and you can use objects normally when they're detached, **except** they will not be able to issue any SQL in order to load collections or attributes which are not yet loaded, or were marked as "expired". The session methods which control instance state include ``add()``, ``delete()``, ``merge()``, and ``expunge()``. The Session object is generally **not** threadsafe. A session which is set to ``autocommit`` and is only read from may be used by concurrent threads if it's acceptable that some object instances may be loaded twice. The typical pattern to managing Sessions in a multi-threaded environment is either to use mutexes to limit concurrent access to one thread at a time, or more commonly to establish a unique session for every thread, using a threadlocal variable. SQLAlchemy provides a thread-managed Session adapter, provided by the :func:`~sqlalchemy.orm.scoped_session` function. t __contains__t__iter__taddtadd_allRbRatclearRsRkRGtdeletetexecutetexpiret expire_alltexpunget expunge_allRNRDt is_modifiedtmergeR trefreshRmtsavetsave_or_updatetscalarR#c Cs|dj o!tidtit|n|oti|_n ti |_|i|_ h|_ h|_ ||_ h|_t|_d|_t||_||_||_||_||_||_ti| pg|_| |_h|_| dj ox| iD]q\} } t| tot | i!} n| |i| Close this Session. This clears all items and ends any transaction in progress. If this session were created with ``autocommit=False``, a new transaction is immediately begun. Note that this new transaction does not use any connection resources until they are first needed. N(RRfR+RIRs(RRf((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRss cCs%xtiD]}|iq WdS(sClose *all* sessions in memory.N(RRlRs(tclstsess((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt close_all s cCsVx.|iit|iD]}|iqW|i|_h|_h|_dS(sRemove all object instances from this ``Session``. This is equivalent to calling ``expunge(obj)`` on all objects in this ``Session``. N(RWRXtlistRKtdetachRRL(RR ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs  sUse session.expunge_all()cCsUt|tot|}n||i|i          cOs|i|||S(s@Return a new ``Query`` object corresponding to this ``Session``.(R(RtentitiesR"((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR |scCs'|io|i o|indS(N(RRMRN(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt _autoflushscCs4x-|iD]\}}|i||iq WdS(N(titemst commit_allRW(RtstatesR tdict_((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyt_finalize_loadeds c Csyti|}Wn%tij oti|nX|i||it|i|i d|d|djo t i dt i|ndS(syRefresh the attributes on the given instance. A query will be issued to the database and all attributes will be refreshed with their current database value. Lazy-loaded relational attributes will remain lazily loaded, so that the instance-wide refresh operation will be followed immediately by the lazy load of that attribute. Eagerly-loaded relational attributes will eagerly load within the single refresh operation. The ``attribute_names`` argument is an iterable collection of attribute names indicating a subset of attributes to be refreshed. t refresh_statetonly_load_propssCould not refresh instance '%s'N(Rtinstance_stateRtNO_STATEtUnmappedInstanceErrort_validate_persistentR t_object_mappert_gettkeyR+R:R;t mapperutilt instance_str(Rtinstancetattribute_namesR ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs cCs4x-|iiD]}t|dd|iqWdS(s5Expires all persistent instances within this Session.RQN(RWRXRYR+(RR ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRsc Csyti|}Wn%tij oti|nX|i||ot|d|d|in\tt d|}t|dd|ix-|D]%\}}}t|dd|iqWdS(sExpire the attributes on an instance. Marks the attributes of an instance as out of date. When an expired attribute is next accessed, query will be issued to the database and the attributes will be refreshed with their current database value. ``expire()`` is a lazy variant of ``refresh()``. The ``attribute_names`` argument is an iterable collection of attribute names indicating a subset of attributes to be expired. RRQsrefresh-expireN( RRRRRRRYRWRt_cascade_state_iteratorR+(RRRR tcascadedtmto((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs  cCs |iiS(sRemove unreferenced instances cached in the identity map. Note that this method is only meaningful if "weak_identity_map" is set to False. The default weak identity map is self-pruning. Removes any object in this Session's identity map that is not referenced in user code, modified, new or scheduled for deletion. Returns the number of objects pruned. (RWtprune(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs cCsyti|}Wn%tij oti|nX|i|ij o tidt i |nxC|ddfgt t d|D]\}}}|i|qWdS(sRemove the `instance` from this ``Session``. This will free all internal references to the instance. Cascading will be applied according to the *expunge* cascade rule. s*Instance %s is not present in this SessionRN(RRRRRt session_idRR:R;Rt state_strR+RRRV(RRR R0RR((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs&cCsv||ijo|ii||inE|ii|o1|ii||ii|d|indS(N(RKR*RRWtcontains_statetdiscardRLR+(RR ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRVscCst|}|i}|dj o|i|}|idjo ||_n.|i|jo|ii|||_n|ii||i|i |in||i jo<|i o|i ot |i i |Qs(t_cascade_unknown_state_iteratorR(RR R((Rs:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRPs cCsyti|}Wn%tij oti|nX|idjo tidt i |n||i jodS|i |t td|}|i|i |<|ii|x$|D]\}}}|i|qWdS(sfMark an instance as deleted. The database delete operation occurs upon ``flush()``. sInstance '%s' is not persistedNR(RRRRRRR+R:R;RRRLt_attachRRRRWRt _delete_impl(RRR tcascade_statesRR((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRTs" c CsPh}|i|i}z&t|_|i|d|d|SWd||_XdS(sCopy the state an instance onto the persistent instance with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy of and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped with ``cascade="merge"``. t dont_loadt _recursiveN(RRR8t_merge(RRRRR((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRvs   c Cst|}||jo ||St}ti|}|i}|djo-|otidn|i|}nd}|o||i jo|i |}q-|o[|i otidn|i i }ti|} || _|i | t}q-|i|ii|d}n|djo5|i i }ti|} t}|i|n|||Object '%s' is already attached to session '%s' (this is '%s')( RRWRR:R;RRRRRct after_attachR(RR Rg((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs      cCsHyti|}Wn%tij oti|nX|i|S(sReturn True if the instance is associated with this session. The instance may be pending or persistent within the Session for a result of True. (RRRRRt_contains_state(RRR ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR}s cCs&tt|ii|iiS(sEIterate over all pending or persistent instances within this Session.(titerRRKRlRW(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR~scCs ||ijp|ii|S(N(RKRWR(RR ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR$scCs`|otidn|iotidnzt|_|i|Wdt|_XdS(sAFlush all the object changes to the database. Writes out all pending object creations, deletions and modifications to the database as INSERTs, DELETEs, UPDATEs, etc. Operations are automatically ordered by the Session's unit of work dependency solver.. Database operations will be issued in the current transactional context and do not affect the state of the transaction. You may flush() as often as you like within a transaction to move changes from Python to the database's transaction buffer. For ``autocommit`` Sessions with no active manual transaction, flush() will create a transaction on the fly that surrounds the entire set of operations int the flush. objects Optional; a list or tuple collection. Restricts the flush operation to only these objects, rather than all pending changes. Deprecated - this flag prevents the session from properly maintaining accounting among inter-object relations and can cause invalid results. sThe 'objects' argument to session.flush() is deprecated; Please do not add objects to the session which should not yet be persisted.sSession is already flushingN(RR)RMR:R;R6t_flushR8(Rtobjects((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRN's   cCs|ii o|i o|i odS|i}| o+|i o |i o|iiidSt|}|io4x$|iD]}|i |||qW|i}nt |i}t |i}t |i |}|oft }x`|D]N}yt i |} Wn%tij oti|nX|i| qWnd}t } |o%|i|i|i |} n|i|i |} x| D]} t| i| } | ot|  odig} tdt| iDD] \}}| d|i|fq ~ }tidti| |fn|i| d| | i| qW|o|i|i | } n|i | } x!| D]} |i| dt qWt!|i"djodS|i#dt |_$}y<|i%x!|iD]}|i&||q W|i'Wn|i(nX|i)x!|iD]}|i*||qpWdS(Ns, nor cssx|]}|iVqWdS(N(tdelete_orphans(t.0R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pys s s9any parent '%s' instance via that classes' '%s' attributesTInstance %s is an unsaved, pending instance and is an orphan (is not attached to %s)tisdeleteiR(+RWtcheck_modifiedRLRKt _dirty_statest _modifiedRRRct before_flushRSt differenceRRRRRRR+RTt intersectionRt _is_orphanRRRtiterate_to_rootR&t FlushErrorRRtregister_objectR6RttasksRbRfRt after_flushRkRmtfinalize_flush_changestafter_flush_postexec(RRtdirtyt flush_contextRgtdeletedtnewtobjsetRR t processedtproct is_orphant_[1]RRtpathRf((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRNs       %L     c Csyti|}Wn%tij oti|nX|i}x|iiD]s}| ot|idpt|id oqQn|ii ||d|\}}} |p| ot SqQWt S(s\Return True if instance has modified attributes. This method retrieves a history instance for each instrumented attribute on the instance and performs a comparison of the current value to its previously committed value. Note that instances present in the 'dirty' collection may result in a value of ``False`` when tested with this method. `include_collections` indicates if multivalued collections should be included in the operation. Setting this to False is a way to detect only local-column based properties (i.e. scalar columns or many-to-one foreign keys) that would result in an UPDATE for this instance upon flush. The `passive` flag indicates if unloaded attributes and collections should not be loaded in the course of performing this test. tget_collectiont get_historytpassive( RRRRRRtmanagerthasattrtimplR$R6R8( RRtinclude_collectionsR%R Rtattrtaddedt unchangedR((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs  $ cCs|io |iiS(s/True if this Session has an active transaction.(RfR?(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR?scCs |iiS(sThe set of all persistent states considered dirty. This method returns all states that were modified including those that were possibly deleted. (RWR (R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR scCsEtig}|iD]'}||ijo||iqq~S(s The set of all persistent instances considered dirty. Instances are considered dirty when they were modified but not deleted. Note that this 'dirty' calculation is 'optimistic'; most attribute-setting or collection modification operations will mark an instance as 'dirty' and place it in this set, even if there is no net change to the attribute's value. At flush time, the value of each attribute is compared to its previously saved value, and if there's no net change, no SQL operation will occur (this is a more expensive operation so it's only done at flush time). To check if an instance has actionable net changes to its attributes, use the is_modified() method. (Rt IdentitySetR RLR(RR!R ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs cCsti|iiS(sDThe set of all instances marked as 'deleted' within this ``Session``(RR-RLRl(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRscCsti|iiS(sAThe set of all instances marked as 'new' within this ``Session``.(RR-RKRl(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs(s __contains__s__iter__saddsadd_allsbegins begin_nestedsclearsclosescommits connectionsdeletesexecutesexpires expire_allsexpunges expunge_allsflushsget_binds is_modifiedsmergesquerysrefreshsrollbackssavessave_or_updatesscalarsupdateN(FR&R'R{tpublic_methodsR+R6R8R tQueryRRbRaRmRkRiRGRRRRsR(RRRt deprecatedRRRRDRRRRRRRRVRRRRR#RRRRRRRRRRRRRURRRR}R~RRNRRR|R?R RRR(((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRsD  1$     "     6              " 6       ' _' cksMt|}x:|i|||D]#\}}ti|||fVq"WdS(N(Rtcascade_iteratorRR(tcascadeR R"RRR((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs  cksGt|}x4|i|||D]\}}t||fVq"WdS(N(RR1R(R2R R"RRR((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs  cCsyti|}Wn"tj oti|nX|o4|idj o tidt i |qn\|oEti |i }|djoti|n|i |}nti||S(Ns#Instance '%s' is already persistent(RRtAttributeErrorRRRR+R:R;RRtmanager_of_classt __class__tsetup_instance(RRR R&((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyRs  cCs?yti|}Wn%tij oti|nX|S(N(RRRRR(RR ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR0s cCstti|S(s:Return the ``Session`` to which instance belongs, or None.(t_state_sessionRR(R((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR8scCs7|io)yt|iSWq3tj oq3XndS(N(RRtKeyErrorR+(R ((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pyR7=s   (R(9R{ROt itertoolsRtsqlalchemy.exceptionst exceptionsR:t sqlalchemyRRRRtsqlalchemy.sqlRRtsqlalchemy.ormRRRR R RR tsqlalchemy.orm.utilR RR RRRRtsqlalchemy.orm.mapperRtsqlalchemy.orm.unitofworkRRt__all__R+R6R8R1R,RRt InstanceStatetexpire_attributesRYtUOWEventHandlertWeakValueDictionaryRRRRRRR7R(((s:/usr/lib/python2.6/site-packages/sqlalchemy/orm/session.pytsF "4  E