ÿØÿà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 dZddlmZddlmZddlmZddlmZddlmZddlmZejZ d e fd YZ d e fd YZ d e fdYZeZejZZejZZejZZdZdZdZdZdS(sDefines SQLAlchemy's system of class instrumentation. This module is usually not directly visible to user applications, but defines a large part of the ORM's interactivity. instrumentation.py deals with registration of end-user classes for state tracking. It interacts closely with state.py and attributes.py which establish per-instance and per-class-attribute instrumentation, respectively. The class instrumentation system can be customized on a per-class or global basis using the :mod:`sqlalchemy.ext.instrumentation` module, which provides the means to build and specify alternate instrumentation forms. .. versionchanged: 0.8 The instrumentation extension system was moved out of the ORM and into the external :mod:`sqlalchemy.ext.instrumentation` package. When that package is imported, it installs itself within sqlalchemy.orm so that its more comprehensive resolution mechanics take effect. i(tbase(t collections(texc(t interfaces(tstatei(tutilt ClassManagercBs6eZdZejZejZee j eZ d,Z ejZd,ZdZdZdZedZedZedZedZe jdZd,d Zd,d Zd Zd Zd Z dZ!e jdZ"dZ#dZ$e j%dZ&e j%dZ'e j%dZ(e)dZ*dZ+dZ,e)dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4e)d Z5d!Z6ed"Z7d,d#Z8d,d$Z9d%Z:d&Z;d'Z<d(Z=e)d)Z>d*Z?e?Z@d+ZARS(-s,tracks state information at the class level.cCs7||_i|_d|_i|_i|_gg|jjD]!}t|tr=t |^q=D]}|dk rb|^qb|_ x|j D]}|j |qW|j j j||x?|jD]4}t |}|dk r|j j|j qqW|j|jd|jkr3tjd|ndS(Nt__del__s__del__() method on class %s will cause unreachable cycles and memory leaks, as SQLAlchemy instrumentation often creates reference cycles. Please remove this method.(tclass_tinfotNonetnew_initt local_attrst originalst __bases__t isinstancettypetmanager_of_classt_basestupdatetdispatcht_eventst_new_classmanager_instancet__mro__t_updatetmanaget_instrument_initt__dict__Rtwarn(tselfRRtmgrtbase_tbasecls((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt__init__:s.     %    cCs t|S(N(tid(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt__hash__`scCs ||kS(N((Rtother((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt__eq__cscCs d|jkS(Ntmapper(R(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt is_mappedfscCs t|S(N(t frozenset(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt _all_key_setjscCs2tg|jD]}|jjr|j^qS(N(R(tvaluestimplt collectiontkey(Rtattr((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_collection_impl_keysnscCs2tg|jD]}|jjr|j^qS(N(R(R*R+taccepts_scalar_loader(RR.((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_scalar_loader_implstscCstj|jdS(N(RtUnmappedClassErrorR(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyR&~sccs|dkrt}nxz|jjD]l}xct|jj|D]I}|j||j|}t|tj rD|j rD||fVqDqDWq%WdS(sreturn an iterator of all classbound attributes that are implement :class:`.InspectionAttr`. This includes :class:`.QueryableAttribute` as well as extension types such as :class:`.hybrid_property` and :class:`.AssociationProxy`. N( R tsetRRRt differencetaddRRtInspectionAttrt is_attribute(RtexcludetsuperclsR-tval((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_all_sqla_attributess     cCs9x2|jjD] }||jkr |j|Sq W|SdS(s5return an attribute on the class without tripping it.N(RRR(RR-tdefaultR9((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_get_class_attr_mroscCs||ko||jdk S(s\Return True if the given attribute is fully initialized. i.e. has an impl. N(R+R (RR-((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_attr_has_implscCs.t|}|dkr*tj|}n|S(sCreate a new ClassManager for a subclass of this ClassManager's class. This is called automatically when attributes are instrumented so that the attributes can be propagated to subclasses against their own class-local manager, without the need for mappers etc. to have already pre-configured managers for the full class hierarchy. Mappers can post-configure the auto-generated ClassManager when needed. N(RR t_instrumentation_factorytcreate_manager_for_cls(Rtclstmanager((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_subclass_managers  cCs;|jj|_t|j||_|jd|jdS(NR!(RR!t original_initt_generate_initR tinstall_member(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRscCs&|jr"|jdd|_ndS(NR!(R tuninstall_memberR (R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_uninstrument_inits  cCs|jj||jtjS(N(Rt first_initRRt InstanceState(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt_state_constructorscCst|j|j|dS(s0Mark this instance as the manager for its class.N(tsetattrRt MANAGER_ATTR(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRscCst|j|jdS(s)Dissasociate this manager from its class.N(tdelattrRRM(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pytdisposescCstS(N(t_default_manager_getter(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pytmanager_getterscCstS(sReturn a (instance) -> InstanceState callable. "state getter" callables should raise either KeyError or AttributeError if no InstanceState could be found for the instance. (t_default_state_getter(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt state_getters cCstS(N(t_default_dict_getter(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt dict_getterscCs|r||jkr9dSn||j|<|j||tj||||s cCs!|r||kS||jkSdS(N(R (RR-tsearch((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pytis_instrumentedEs cCs ||jS(N(R+(RR-((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRsKscCst|jS(N(titerR*(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt attributesNscCsJ|jj|j}|dkr6|j||}n|j|||S(N(Rt__new__R RKt _state_setter(RRtinstance((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt new_instanceTs  cCs5|dkr!|j||}n|j||dS(N(R RKR}(RR~R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pytsetup_instance[s cCst||jdS(N(RNRh(RR~((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pytteardown_instance`scCs t||S(N(t_SerializeManager(RRt state_dict((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt _serializecscCstt||jrtS|j|jk rJ|jrJ|j|jj|S|j||}|j |||SdS(sInstall a default InstanceState if none is present. A private convenience method used by the __init__ decorator. N( thasattrRhtFalseRt __class__R'RCt_new_state_if_noneRKR}(RR~R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRfs cCst||jS(N(RRh(RR~((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt has_state|scCs|j|j|d|S(tTODOt optimistic(Rst hasparent(RRR-R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt has_parentscCstS(s=All ClassManagers are non-zero regardless of attribute state.(R[(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt__bool__scCs d|jj|jt|fS(Ns<%s of %r at %x>(Rt__name__RR"(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt__repr__s N(BRt __module__t__doc__RtDEFAULT_MANAGER_ATTRRMtDEFAULT_STATE_ATTRRht staticmethodRt attrsetterR}R tdeferred_scalar_loadertobjectR!RDRtR#R%tpropertyR'RWR)R/R1tmemoized_propertyR&R;R=R>RCRRHRKRROt hybridmethodRQRSRURRZR^RbRdRgRVRcRFRGRqRwRyRsR{RRRRRRRRt __nonzero__R(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyR,sf    &                            RcBs eZdZdZdZRS(sProvide serialization of a :class:`.ClassManager`. The :class:`.InstanceState` uses ``__init__()`` on serialize and ``__call__()`` on deserialize. cCs,|j|_|j}|jj||dS(N(RRBRtpickle(RRtdRB((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyR!s  cCst|j|_}|dkr>tj|d|jn&|jrd|jj rd|jj n|dk r|j ||n|j j ||dS(NsxCannot deserialize object of type %r - no mapper() has been configured for this class within the current Python process!( RRRBR RtUnmappedInstanceErrorR'R&t configuredt_configure_allRRtunpickle(RRR\RRB((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyt__call__s  (RRRR!R(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRs tInstrumentationFactorycBs2eZdZdZdZdZdZRS(s'Factory for new ClassManager instances.cCs|dk stt|dks*t|j|\}}|dkr`t}||}n|j||||_|jj||S(N( R tAssertionErrorRt_locate_extended_factoryRt_check_conflictsRtRtclass_instrument(RRRBRt((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyR@s  cCsdS(s2Overridden by a subclass to do an extended lookup.N(NN(R (RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRscCsdS(s;Overridden by a subclass to test for conflicting factories.N((RRRt((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRscCsYt|}|j|j|jj|tj|jkrUt|tjndS(N( RRgRORtclass_uninstrumentRRMRRN(RRRB((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRgs    (RRRR@RRRg(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRs    cCs.t|}|dkr*tj|}n|S(s_Register class instrumentation. Returns the existing or newly created class manager. N(RR R?R@(RRB((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pytregister_classs  cCstj|dS(s!Unregister class instrumentation.N(R?Rg(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pytunregister_classscCst|jj|dtS(sReturn True if the given attribute on the given instance is instrumented by the attributes package. This function may be used regardless of instrumentation applied directly to the class, i.e. no descriptors are required. Rx(RRRyR[(R~R-((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyRysc Bs|j}|std}ej|de}||}ejrje|d|}e|dd}n$e|dd}e|dd}ej } || U| d} |j | _ || _ |r|| _ nej r|r|| _ n| S( s>Build an __init__ decorator that triggers ClassManager events.sdef __init__(%(apply_pos)s): new_state = class_manager._new_state_if_none(%(self_arg)s) if new_state: return new_state._initialize_instance(%(apply_kw)s) else: return original__init__(%(apply_kw)s) tgroupedtim_funct func_defaultst __defaults__t__kwdefaults__R!N(R!RRtformat_argspec_initRtpy2kRkR tlocalstcopyRt_sa_original_initRR( Rt class_managertoriginal__init__t func_bodyt func_varst func_texttfuncRtfunc_kw_defaultstenvR!((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyREs(         N(RtRRRRRRt!group_expirable_memoized_propertyRWtdictRRRRR?tinstance_stateRRt instance_dictRTRRPRRRyRE(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/instrumentation.pyts& f")