ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ 4]c@s dZddlZddlZddlmZddlmZddlmZddlm Z dd l m Z d d d d dgZ e j jZdefdYZdefdYZdefdYZdZdefdYZdZdZd efdYZejdZdefdYZedZdZd Zd!Z d"Z!d#Z"d$Z#d%Z$d&Z%ed'Z&ed(Z'ed)Z(d*Z)d+Z*e+e,fZ-d,Z.d-Z/d.Z0d/e1fd0YZ2d1e+fd2YZ3d3e4fd4YZ5ie2e16e3e+6e5e46Z6iid5d66d7d86d9d:6e)fe16id;d66d7d86d9d:6e0fe+6e j7rid<d:6e*fnid=d:6e*fe46Z8d>e4fd?YZ9e e9e e2e e3dS(@sNSupport for collections of mapped entities. The collections package supplies the machinery used to inform the ORM of collection membership changes. An instrumentation via decoration approach is used, allowing arbitrary types (including built-ins) to be used as entity collections without requiring inheritance from a base class. Instrumentation decoration relays membership change events to the :class:`.CollectionAttributeImpl` that is currently managing the collection. The decorators observe function call arguments and return values, tracking entities entering or leaving the collection. Two decorator approaches are provided. One is a bundle of generic decorators that map function arguments and return values to events:: from sqlalchemy.orm.collections import collection class MyClass(object): # ... @collection.adds(1) def store(self, item): self.data.append(item) @collection.removes_return() def pop(self): return self.data.pop() The second approach is a bundle of targeted decorators that wrap appropriate append and remove notifiers around the mutation methods present in the standard Python ``list``, ``set`` and ``dict`` interfaces. These could be specified in terms of generic decorator recipes, but are instead hand-tooled for increased efficiency. The targeted decorators occasionally implement adapter-like behavior, such as mapping bulk-set methods (``extend``, ``update``, ``__setslice__``, etc.) into the series of atomic mutation events that the ORM requires. The targeted decorators are used internally for automatic instrumentation of entity collection classes. Every collection class goes through a transformation process roughly like so: 1. If the class is a built-in, substitute a trivial sub-class 2. Is this class already instrumented? 3. Add in generic decorators 4. Sniff out the collection interface through duck-typing 5. Add targeted decoration to any undecorated interface method This process modifies the class at runtime, decorating methods and adding some bookkeeping properties. This isn't possible (or desirable) for built-in classes like ``list``, so trivial sub-classes are substituted to hold decoration:: class InstrumentedList(list): pass Collection classes can be specified in ``relationship(collection_class=)`` as types or a function that returns an instance. Collection classes are inspected and instrumented during the mapper compilation phase. The collection_class callable will be executed once to produce a specimen instance, and the type of that specimen will be instrumented. Functions that return built-in types like ``lists`` will be adapted to produce instrumented instances. When extending a known type like ``list``, additional decorations are not generally not needed. Odds are, the extension method will delegate to a method that's already instrumented. For example:: class QueueIsh(list): def push(self, item): self.append(item) def shift(self): return self.pop(0) There's no need to decorate these methods. ``append`` and ``pop`` are already instrumented as part of the ``list`` interface. Decorating them would fire duplicate events, which should be avoided. The targeted decoration tries not to rely on other methods in the underlying collection class, but some are unavoidable. Many depend on 'read' methods being present to properly instrument a 'write', for example, ``__setitem__`` needs ``__getitem__``. "Bulk" methods like ``update`` and ``extend`` may also reimplemented in terms of atomic appends and removes, so the ``extend`` decoration will actually perform many ``append`` operations and not call the underlying method at all. Tight control over bulk operation and the firing of events is also possible by implementing the instrumentation internally in your methods. The basic instrumentation package works under the general assumption that collection mutation will not raise unusual exceptions. If you want to closely orchestrate append and remove events with exception management, internal instrumentation may be the answer. Within your method, ``collection_adapter(self)`` will retrieve an object that you can use for explicit control over triggering append and remove events. The owning object and :class:`.CollectionAttributeImpl` are also reachable through the adapter, allowing for some very sophisticated behavior. iN(tinspect_getfullargspeci(tbasei(texc(tutil(t expressiont collectiontcollection_adaptertmapped_collectiontcolumn_mapped_collectiontattribute_mapped_collectiont_PlainColumnGettercBs2eZdZdZdZdZdZRS(sPlain column getter, stores collection of Column objects directly. Serializes to a :class:`._SerializableColumnGetterV2` which has more expensive __call__() performance and some rare caveats. cCs"||_t|dk|_dS(Ni(tcolstlent composite(tselfR ((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__init__s cCstj|jS(N(t_SerializableColumnGetterV2t_reduce_from_colsR (R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt __reduce__scCs|jS(N(R (Rtmapper((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt_colsscCsqtj|}tj|}g|j|D]}|j||j|^q.}|jret|S|dSdS(Ni(Rtinstance_statet _state_mapperRt_get_state_attr_by_columntdictR ttuple(Rtvaluetstatetmtcoltkey((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__call__s1  (t__name__t __module__t__doc__RRRR(((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR s    t_SerializableColumnGettercBs)eZdZdZdZdZRS(slColumn-based getter used in version 0.7.6 only. Remains here for pickle compatibility with 0.7.6. cCs"||_t|dk|_dS(Ni(tcolkeysR R (RR$((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs cCst|jffS(N(R#R$(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRscCsutj|}tj|}g|jD](}|j||j|jj|^q(}|jrit |S|dSdS(Ni( RRRR$RRt mapped_tabletcolumnsR R(RRRRtkR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs5  (R R!R"RRR(((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR#s  RcBs8eZdZdZdZedZdZRS(s<Updated serializable getter which deals with multi-table mapped classes. Two extremely unusual cases are not supported. Mappings which have tables across multiple metadata objects, or which are mapped to non-Table selectables linked across inheriting mappers may fail to function here. cCs"||_t|dk|_dS(Ni(R$R R (RR$((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs cCs|j|jffS(N(t __class__R$(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRscCs>d}g|D]}|j||f^q}t|ffS(NcSs't|jtjsdS|jjSdS(N(t isinstancettableRt TableClausetNoneR(tc((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt _table_keys(RR(tclsR R.R-R$((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs (cCsg}t|jdd}xp|jD]e\}}|dksU|dksU||kro|j|jj|q%|j|j|j|q%W|S(Ntmetadata(tgetattrt local_tableR,R$tappendR-ttables(RRR R0tckeyttkey((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs$(R R!R"RRt classmethodRR(((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs     csGgtj|D]}tj|d^q}t|fdS(sA dictionary-based collection type with column-based keying. Returns a :class:`.MappedCollection` factory with a keying function generated from mapping_spec, which may be a Column or a sequence of Columns. The key value must be immutable for the lifetime of the object. You can not, for example, map on foreign key values if those key values will change during the session, i.e. from None to a database-assigned integer after a session flush. t mapping_speccs tS(N(tMappedCollection((tkeyfunc(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytt(Rtto_listRt_only_column_elementsR (R8tqR ((R:sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs+ t_SerializableAttrGettercBs#eZdZdZdZRS(cCs||_tj||_dS(N(tnametoperatort attrgettertgetter(RRA((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs cCs |j|S(N(RD(Rttarget((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRscCst|jffS(N(R@RA(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs(R R!RRR(((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR@s  cst|fdS(sA dictionary-based collection type with attribute-based keying. Returns a :class:`.MappedCollection` factory with a keying based on the 'attr_name' attribute of entities in the collection, where ``attr_name`` is the string name of the attribute. The key value must be immutable for the lifetime of the object. You can not, for example, map on foreign key values if those key values will change during the session, i.e. from None to a database-assigned integer after a session flush. cs tS(N(R9((RD(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR;R<(R@(t attr_name((RDsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR s cs fdS(sA dictionary-based collection type with arbitrary keying. Returns a :class:`.MappedCollection` factory with a keying function generated from keyfunc, a callable that takes an entity and returns a key value. The key value must be immutable for the lifetime of the object. You can not, for example, map on foreign key values if those key values will change during the session, i.e. from None to a database-assigned integer after a session flush. cs tS(N(R9((R:(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR;'R<((R:((R:sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs cBseZdZedZedZedZedZeej dddZ e Z eej dd d Z ed Z ed Zed ZedZRS(s}Decorators for entity collection classes. The decorators fall into two groups: annotations and interception recipes. The annotating decorators (appender, remover, iterator, linker, converter, internally_instrumented) indicate the method's purpose and take no arguments. They are not written with parens:: @collection.appender def append(self, append): ... The recipe decorators all require parens, even those that take no arguments:: @collection.adds('entity') def insert(self, position, entity): ... @collection.removes_return() def popitem(self): ... cCs d|_|S(sTag the method as the collection appender. The appender method is called with one positional argument: the value to append. The method will be automatically decorated with 'adds(1)' if not already decorated:: @collection.appender def add(self, append): ... # or, equivalently @collection.appender @collection.adds(1) def add(self, append): ... # for mapping type, an 'append' may kick out a previous value # that occupies that slot. consider d['a'] = 'foo'- any previous # value in d['a'] is discarded. @collection.appender @collection.replaces(1) def add(self, entity): key = some_key_func(entity) previous = None if key in self: previous = self[key] self[key] = entity return previous If the value to append is not allowed in the collection, you may raise an exception. Something to remember is that the appender will be called for each object mapped by a database query. If the database contains rows that violate your collection semantics, you will need to get creative to fix the problem, as access via the collection will not work. If the appender method is internally instrumented, you must also receive the keyword argument '_sa_initiator' and ensure its promulgation to collection events. tappender(t_sa_instrument_role(tfn((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRGDs) cCs d|_|S(sTag the method as the collection remover. The remover method is called with one positional argument: the value to remove. The method will be automatically decorated with :meth:`removes_return` if not already decorated:: @collection.remover def zap(self, entity): ... # or, equivalently @collection.remover @collection.removes_return() def zap(self, ): ... If the value to remove is not present in the collection, you may raise an exception or return None to ignore the error. If the remove method is internally instrumented, you must also receive the keyword argument '_sa_initiator' and ensure its promulgation to collection events. tremover(RH(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRJps cCs d|_|S(sTag the method as the collection remover. The iterator method is called with no arguments. It is expected to return an iterator over all collection members:: @collection.iterator def __iter__(self): ... titerator(RH(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRKs cCs t|_|S(sTag the method as instrumented. This tag will prevent any decoration from being applied to the method. Use this if you are orchestrating your own calls to :func:`.collection_adapter` in one of the basic SQLAlchemy interface methods, or to prevent an automatic ABC method decoration from wrapping your implementation:: # normally an 'extend' method on a list-like class would be # automatically intercepted and re-implemented in terms of # SQLAlchemy events and append(). your implementation will # never be called, unless: @collection.internally_instrumented def extend(self, items): ... (tTruet_sa_instrumented(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytinternally_instrumenteds s1.0sThe :meth:`.collection.linker` handler is deprecated and will be removed in a future release. Please refer to the :meth:`.AttributeEvents.init_collection` and :meth:`.AttributeEvents.dispose_collection` event handlers. cCs d|_|S(sTag the method as a "linked to attribute" event handler. This optional event handler will be called when the collection class is linked to or unlinked from the InstrumentedAttribute. It is invoked immediately after the '_sa_adapter' property is set on the instance. A single argument is passed: the collection adapter that has been linked, or None if unlinking. tlinker(RH(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyROs s1.3sThe :meth:`.collection.converter` handler is deprecated and will be removed in a future release. Please refer to the :class:`.AttributeEvents.bulk_replace` listener interface in conjunction with the :func:`.event.listen` function.cCs d|_|S(sTag the method as the collection converter. This optional method will be called when a collection is being replaced entirely, as in:: myobj.acollection = [newvalue1, newvalue2] The converter method will receive the object being assigned and should return an iterable of values suitable for use by the ``appender`` method. A converter must not assign values or mutate the collection, its sole job is to adapt the value the user provides into an iterable of values for the ORM's use. The default converter implementation will use duck-typing to do the conversion. A dict-like collection will be convert into an iterable of dictionary values, and other types will simply be iterated:: @collection.converter def convert(self, other): ... If the duck-typing of the object does not match the type of this collection, a TypeError is raised. Supply an implementation of this method if you want to expand the range of possible types that can be assigned in bulk or perform validation on the values about to be assigned. t converter(RH(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRPs% csfd}|S(sMark the method as adding an entity to the collection. Adds "add to collection" handling to the method. The decorator argument indicates which method argument holds the SQLAlchemy-relevant value. Arguments can be specified positionally (i.e. integer) or by name:: @collection.adds(1) def push(self, item): ... @collection.adds('entity') def do_stuff(self, thing, entity=None): ... csdf|_|S(Ntfire_append_event(t_sa_instrument_before(RI(targ(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt decorators((RSRT((RSsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytaddsscsfd}|S(sMark the method as replacing an entity in the collection. Adds "add to collection" and "remove from collection" handling to the method. The decorator argument indicates which method argument holds the SQLAlchemy-relevant value to be added, and return value, if any will be considered the value to remove. Arguments can be specified positionally (i.e. integer) or by name:: @collection.replaces(2) def __setitem__(self, index, item): ... csdf|_d|_|S(NRQtfire_remove_event(RRt_sa_instrument_after(RI(RS(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRTs ((RSRT((RSsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytreplaces scsfd}|S(sMark the method as removing an entity in the collection. Adds "remove from collection" handling to the method. The decorator argument indicates which method argument holds the SQLAlchemy-relevant value to be removed. Arguments can be specified positionally (i.e. integer) or by name:: @collection.removes(1) def zap(self, item): ... For methods where the value to remove is not known at call-time, use collection.removes_return. csdf|_|S(NRV(RR(RI(RS(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRT3s((RSRT((RSsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytremoves"scCs d}|S(sMark the method as removing an entity in the collection. Adds "remove from collection" handling to the method. The return value of the method, if any, is considered the value to remove. The method arguments are not inspected:: @collection.removes_return() def pop(self): ... For methods where the value to remove is known at call-time, use collection.remove. cSs d|_|S(NRV(RW(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRTIs ((RT((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytremoves_return9s (R R!R"t staticmethodRGRJRKRNRt deprecatedROtlinkRPRURXRYRZ(((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR*s$,%t _sa_adaptertCollectionAdaptercBseZdZdZdZdZed Zed Zd Z dd Z d Z dZ dZddZdZddZdZdZdZdZeZddZddZddZdZdZRS(siBridges between the ORM and arbitrary Python collections. Proxies base-level collection operations (append, remove, iterate) to the underlying Python collection, and emits add/remove events for entities entering or leaving the collection. The ORM uses :class:`.CollectionAdapter` exclusively for interaction with entity collections. tattrt_keyt_datat owner_statet _convertert invalidatedcCsR||_|j|_tj||_||_||_|j|_ t |_ dS(N( R`RRatweakreftrefRbRcR^t _sa_converterRdtFalseRe(RR`Rctdata((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRjs     cCstjddS(Ns%This collection has been invalidated.(Rtwarn(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt_warn_invalidatedsscCs |jS(s$The entity collection being adapted.(Rb(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRjvscCs|jj|j|jkS(sreturn True if the owner state still refers to this collection. This will return False within a bulk replace operation, where this collection is the one being replaced. (RcRRaRb(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt_referenced_by_owner{scCs |jjS(N(Rbt _sa_appender(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt bulk_appenderscCs|jj|d|dS(s8Add an entity to the collection, firing mutation events.t _sa_initiatorN(RbRn(Rtitemt initiator((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytappend_with_eventscCs|jj|dtdS(s=Add or restore an entity to the collection, firing no events.RpN(RbRnRi(RRq((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytappend_without_eventscCs4|jj}x|D]}||dtqWdS(s=Add or restore an entity to the collection, firing no events.RpN(RbRnRi(RtitemsRGRq((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytappend_multiple_without_events cCs |jjS(N(Rbt _sa_remover(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt bulk_removerscCs|jj|d|dS(s=Remove an entity from the collection, firing mutation events.RpN(RbRw(RRqRr((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytremove_with_eventscCs|jj|dtdS(s7Remove an entity from the collection, firing no events.RpN(RbRwRi(RRq((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytremove_without_eventscCs:|jj}x$t|D]}||d|qWdS(s>Empty the collection, firing a mutation event for each entity.RpN(RbRwtlist(RRrRJRq((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytclear_with_eventscCs:|jj}x$t|D]}||dtqWdS(s'Empty the collection, firing no events.RpN(RbRwR{Ri(RRJRq((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytclear_without_eventscCst|jjS(s(Iterate over entities in the collection.(titerRbt _sa_iterator(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__iter__scCstt|jjS(s!Count entities in the collection.(R R{RbR(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__len__scCstS(N(RL(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__bool__scCsL|tk rD|jr"|jn|jj|j|jj||S|SdS(s Notify that a entity has entered the collection. Initiator is a token owned by the InstrumentedAttribute that initiated the membership mutation, and should be left as None unless you are passing along an initiator value from a chained operation. N(RiReRlR`RQRcR(RRqRr((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRQs    cCsK|tk rG|jr"|jn|jj|j|jj||ndS(sNotify that a entity has been removed from the collection. Initiator is the InstrumentedAttribute that initiated the membership mutation, and should be left as None unless you are passing along an initiator value from a chained operation. N(RiReRlR`RVRcR(RRqRr((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRVs     cCs<|jr|jn|jj|j|jjd|dS(sNotify that an entity is about to be removed from the collection. Only called if the entity cannot be removed after calling fire_remove_event(). RrN(ReRlR`tfire_pre_remove_eventRcR(RRr((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs   cCs9i|jd6|jd6|jjd6|jd6|jd6S(NRRct owner_clsRjRe(RaRctclass_RjRe(R((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt __getstate__s     cCsz|d|_|d|_tj|d|_|dj|_||d_|d|_t |d|jj |_ dS(NRRcRjReR( RaRcRfRgRbRhRdR^ReR1timplR`(Rtd((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt __setstate__s    (R`RaRbRcRdReN(R R!R"t __slots__RRltpropertyRjRmRoR,RsRtRvRxRyRzR|R}RRRt __nonzero__RQRVRRR(((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR_Ts:                 c Cst|tsttj}||p*d}|j|p?d}||pQdj|}|j|}|j} xR|pdD]D} | |kr| | d|q| |kr| | dtqqW|rx$|D]} |j | d|qWndS(sFLoad a new collection, firing events based on prior like membership. Appends instances in ``values`` onto the ``new_adapter``. Events will be fired for any instance not present in the ``existing_adapter``. Any instances in ``existing_adapter`` not present in ``values`` will have remove events fired upon them. :param values: An iterable of collection member instances :param existing_adapter: A :class:`.CollectionAdapter` of instances to be replaced :param new_adapter: An empty :class:`.CollectionAdapter` to load with ``values`` RpRrN((((( R)R{tAssertionErrorRt IdentitySett intersectiont differenceRoRiRV( tvaluestexisting_adaptert new_adapterRrtidsettexisting_idsett constantst additionstremovalsRGtmember((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt bulk_replaces     cCs|tkrt|}nt|}|tkrOt||}|}ntjrz/t|ddt|krt|nWdtj Xn|S(soPrepare a callable for future use as a collection class factory. Given a collection class factory (either a type or no-arg callable), return another factory that will produce compatible instances when called. This function is responsible for converting collection_class=list into the run-time behavior of collection_class=InstrumentedList. RMN( t__canned_instrumentationttypet__converting_factoryt__instrumentation_mutextacquireR1R,tidt_instrument_classtrelease(tfactoryR/((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytprepare_instrumentation's     cs<t|fd}dj|_j|_|S(ssReturn a wrapper that converts a "canned" collection like set, dict, list into the Instrumented* version. cs}|S(N((R(tinstrumented_clstoriginal_factory(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytwrapperRs s %sWrapper(RR R"(t specimen_clsRR((RRsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRJs   cCsg|jdkr!tjdnt|\}}t|||t|||t|||dS(s6Modify methods in a class and install instrumentation.t __builtin__sGCan not instrument a built-in type. Use a subclass, even a trivial one.N(R!tsa_exct ArgumentErrort_locate_roles_and_methodst_setup_canned_rolest_assert_required_rolest_set_collection_attributes(R/trolestmethods((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR]s c CsSi}i}x:|jD]/}x&t|jD]\}}tj|sPq/nt|dr|j}|d kszt|j||nd \}}t|dr|j \} } | dkst| | f}nt|d r |j } | dkst| }n|r%||f|||d|krwtt||dd rwd ||d|d|krtt||dd rd ||dType %s must elect an appender method to be a collection classRMRQiRJs<Type %s must elect a remover method to be a collection classRVRKs>Type %s must elect an iterator method to be a collection classN(RQiN(RViN(RRRR R1R,(R/RR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs$   c CsxK|jD]=\}\}}}t||tt|||||q Wx7|jD])\}}t|d|t||q[Wd|_t|dsd|_nt||_ dS(skapply ad-hoc instrumentation from decorators, class-level defaults and implicit role declarations s_sa_%sRhN( RuRt_instrument_membership_mutatorR1R,R^RRhRRM(R/RRt method_nameRRRR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs" !  csrttjtd}ttr_t|krV|pYdn*|kr}|jnd~nfd}t |_ t drj |_ nj |_ j|_|S(sIRoute method args and/or return value through the collection adapter.ics?rdkrA|kr4tjdn|}qt|kr`|}q|kry|}qtjdn|jdd}|tkrd}n |dj}r|rt|||n s| r||S||}|dk r7t|||n|SdS(NsMissing argument %sRpi(R,RRR tpopRiR^R1(targstkwRRrtexecutortres(RRRRt named_argtpos_arg(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs0            RHN(R{Rtflatten_iteratorRR)tintR R,tindexRLRMRRHR R"(RRRRtfn_argsR((RRRRRRsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs$% #   cCs7|tk r3|j}|r3|j||}q3n|S(s^Run set events. This event always occurs before the collection is actually mutated. (RiR^RQ(RRqRpR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__set,s   cCs5|tk r1|j}|r1|j||q1ndS(sRun del events. This event occurs before the collection is actually mutated, *except* in the case of a pop operation, in which case it occurs afterwards. For pop operations, the __before_pop hook is called before the operation occurs. N(RiR^RV(RRqRpR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__del:s  cCs#|j}|r|j|ndS(s;An event which occurs on a before a pop() operation occurs.N(R^R(RRpR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt __before_popIs c sdfd}fd}fd}fd}fd}tjr~fd}fd}nfd }fd }fd } tjsfd } ntj} | jd | S(s:Tailored instrumentation wrappers for any list-like class.cSs%t|_tt|jj|_dS(N(RLRMR1R{R R"(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt_tidySs cs dfd}||S(Ncs#t|||}||dS(N(R(RRqRp(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR3Xs(R,(RIR3(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR3Ws cs dfd}||S(Ncs!t|||||dS(N(R(RRRp(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytremove`s(R,(RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR_s csfd}||S(Ncs#t||}|||dS(N(R(RRR(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytinsertis((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRhs csfd}||S(Nc st|tsW||}|dk r5t||nt||}|||n|jpcd}|jprd}|dkr|t|7}n|jdk r|j}n t|}|dkr|t|7}n|dkrSx6t |||D]"}t||kr||=qqWxt |D] \}}|j |||q,Wnt t |||} t|t| krt dt|t| fnx-t| |D]\}}|j||qWdS(NiisBattempt to assign sequence of size %s to extended slice of size %s(R)tsliceR,RRtsteptstartR tstoptranget enumerateRR{t ValueErrortzipt __setitem__( RRRtexistingRRRtiRqtrng(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRqs8       ((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRps& csfd}||S(Ncsit|ts6||}t||||n/x||D]}t||qAW||dS(N(R)RR(RRRq(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt __delitem__s  ((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs csfd}||S(Ncs^x"|||!D]}t||qWg|D]}t||^q,}||||dS(N(RR(RRtendRR(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt __setslice__s"((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs csfd}||S(Ncs9x"|||!D]}t||qW|||dS(N(R(RRRR(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt __delslice__s((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs csd}||S(NcSs"x|D]}|j|qWdS(N(R3(RtiterableR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytextends ((RIR(R(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs  csd}||S(NcSs"x|D]}|j|qW|S(N(R3(RRR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt__iadd__s ((RIR(R(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs  cs dfd}||S(Nics*t|||}t|||S(N(RR(RRRq(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs  ((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs cs dfd}||S(Nics,x|D]}t||qW|dS(N(R(RRRq(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytclears ((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs R(Rtpy2ktlocalstcopyR( R3RRRRRRRRRRtl((RsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyt_list_decoratorsPs"  *      csdtjdfd}fd}fd}fd}fd}fd}fd }tj}|jd |jd|S( sBTailored instrumentation wrappers for any dict-like mapping class.cSs%t|_tt|jj|_dS(N(RLRMR1RR R"(RI((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs t Unspecifiedcs dfd}||S(NcsI||kr#t||||nt|||}|||dS(N(RR(RRRRp(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs (R,(RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs cs dfd}||S(Ncs4||kr#t||||n||dS(N(R(RRRp(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs (R,(RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs csfd}||S(Ncs0x|D]}t|||qW|dS(N(R(RR(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs ((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs cs#fd}||S(Ncs`t|||k}|kr4||}n|||}|r\t||n|S(N(RR(RRtdefaultt_to_delRq(RRI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs   ((RIR(RR(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyRs csfd}||S(Ncs+t||}t||d|S(Ni(RR(RRq(RI(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pytpopitem's  ((RIR(R(RIsM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR&s csdd}||S(NcSs1||kr |j|||S|j|SdS(N(Rt __getitem__(RRR((sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR1s (R,(RIR(R(sM/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/collections.pyR0s  cs fd}||S(Ncs|k rt|drfxt|D]7}||ksN||||k r(||||hsx   #)   ' ( #   ,   >    a       9