ÿØÿà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@sdZddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z dd lmZdd lmZddlmZejeZd efd YZd efdYZdefdYZejdddZejdddZe jdZejejdddZejejdddZ ej!Ze j"Z ej#Z#dS(sBaked query extension. Provides a creational pattern for the :class:`.query.Query` object which allows the fully constructed object, Core select statement, and string compiled result to be fully cached. iNi(texc(tutil(tstrategy_options(tQuery(tSession(tfunc(tliteral_columntBakerycBs&eZdZdZdZdZRS(sCallable which returns a :class:`.BakedQuery`. This object is returned by the class method :meth:`.BakedQuery.bakery`. It exists as an object so that the "cache" can be easily inspected. .. versionadded:: 1.2 tclstcachecCs||_||_dS(N(RR (tselftcls_R ((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt__init__/s cGs|j|j||S(N(RR (R t initial_fntargs((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt__call__3s(RR (t__name__t __module__t__doc__t __slots__R R(((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR!s  t BakedQuerycBseZdZdZddZedddZdZdd Z d Z d Z d Z d Z dZdZedZdZddZddZdZdZdZdZdZdZRS(s3A builder object for :class:`.query.Query` objects.tstepst_bakeryt _cache_keyt_spoiledcCs;d|_|j|||g|_t|_||_dS(N((Rt_update_cache_keyRtFalseRR(R tbakeryR R((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR <s    icCst|tj|d|S(sSConstruct a new bakery. :return: an instance of :class:`.Bakery` t size_alert(RRtLRUCache(Rtsizet _size_alert((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRCscCsItjt}|j|_t|j|_|j|_|j|_|S(N(Rt__new__RtlistRRR(R tb1((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt_cloneMs    cCs|j|jf|7_dS(N(Rt__code__(R tfnR((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRUscCs0t|tr|j|n |j||S(N(t isinstancettuplet add_criteria(R tother((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt__iadd__Xs cCs-t|tr|j|S|j|SdS(N(R&R't with_criteria(R R)((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt__add___s cGs$|j|||jj||S(sAdd a criteria function to this :class:`.BakedQuery`. This is equivalent to using the ``+=`` operator to modify a :class:`.BakedQuery` in-place. (RRtappend(R R%R((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR(escGs|jj||S(sAdd a criteria function to a :class:`.BakedQuery` cloned from this one. This is equivalent to using the ``+`` operator to produce a new :class:`.BakedQuery` with modifications. (R#R((R R%R((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR+pscCs t||S(sReturn a :class:`.Result` object for this :class:`.BakedQuery`. This is equivalent to calling the :class:`.BakedQuery` as a Python callable, e.g. ``result = my_baked_query(session)``. (tResult(R tsession((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt for_sessionyscCs |j|S(N(R0(R R/((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRscCsK| r>|j r>|j}|jd7_|jg|_nt|_|S(szCancel any query caching that will occur on this BakedQuery object. The BakedQuery can continue to be used normally, however additional creational functions will not be cached; they will be called on every invocation. This is to support the case where a particular step in constructing a baked query disqualifies the query from being cacheable, such as a variant that relies upon some uncacheable value. :param full: if False, only functions added to this :class:`.BakedQuery` object subsequent to the spoil step will be non-cached; the state of the :class:`.BakedQuery` up until this point will be pulled from the cache. If True, then the entire :class:`.Query` object is built from scratch each time, with all creational functions being called on each invocation. t _query_only(R1(RR#Rt_retrieve_baked_queryRtTrue(R tfullt _spoil_point((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytspoils   cCs|j|jfS(sReturn the key that actually goes into the cache dictionary for this :class:`.BakedQuery`, taking into account the given :class:`.Session`. This basically means we also will include the session's query_class, as the actual :class:`.Query` object is part of what's cached and needs to match the type of :class:`.Query` that a later session will want to use. (Rt _query_cls(R R/((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt_effective_keys cCs&|j}|j||d||S(s2Cloning version of _add_lazyload_options. t cache_path(R#t_add_lazyload_options(R toptionsteffective_pathR9tq((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt_with_lazyload_optionss csd}|s}n|jdjr2|jnRxOD]G}|j|}|tkrg|jq9|dk r9||7}q9q9W|jfd|j|dS(s*Used by per-state lazy loaders to add options to the "lazy load" query from a parent query. Creates a cache key based on given load path and query options; if a repeatable cache key cannot be generated, the query is "spoiled" so that it won't use caching. ics|jjS(N(t_with_current_patht_conditional_options(R=(R<R;(sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyts N((tpathtis_aliased_classR6t_generate_cache_keyRtNoneR((R R;R<R9tkeytoptt cache_key((R<R;sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR:s       cCsh|jj|j|d}|dkr[|j|}|jd|j|j|R:R2R[RaRJRTRo(((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR7s.         #  4  R.cBseZdZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZdZRS(s Invokes a :class:`.BakedQuery` against a :class:`.Session`. The :class:`.Result` object is where the actual :class:`.query.Query` object gets created, or retrieved from the cache, against a target :class:`.Session`, and is then invoked for results. tbqR/t_paramst_post_criteriacCs(||_||_i|_g|_dS(N(RqR/RrRs(R RqR/((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR ds   cOs^t|dkr&|j|dn$t|dkrJtjdn|jj||S(s@Specify parameters to be replaced into the string SQL statement.iisFparams() takes zero or one positional argument, which is a dictionary.(tlentupdateR\R]Rr(R Rtkw((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRmjs cCs|r|jj|n|S(N(Rstextend(R tfns((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt_using_post_criteriawscCs|j|gS(sAdd a criteria function that will be applied post-cache. This adds a function that will be run against the :class:`.Query` object after it is retrieved from the cache. Functions here can be used to alter the query in ways that **do not affect the SQL output**, such as execution options and shard identifiers (when using a shard-enabled query object) .. warning:: :meth:`.Result.with_post_criteria` functions are applied to the :class:`.Query` object **after** the query's SQL statement object has been retrieved from the cache. Any operations here which intend to modify the SQL should ensure that :meth:`.BakedQuery.spoil` was called first. .. versionadded:: 1.2 (Ry(R R%((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRl|scCsE|jj|jj|j}x|jD]}||}q+W|S(N(RqRJR/RmRrRs(R R=R%((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRJs!cCst|jS(N(tstrRJ(R ((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt__str__scCs:|j}|jj s|jr/t|jS|jj|j|jd}|dkrq|j |j}nt j |}|j|_|j j |_ |j |j||j|jt|j_|jr|j r|jjn|jj|jj|j}x|jD]}||}qW|j|S(N(RqR/tenable_baked_queriesRtiterRJRRIR8RER[tcopyRgRoRrRsR3t statementt use_labelst autoflushtpopulate_existingt _autoflushRLRmRKt_execute_and_instances(R Rqt baked_contextRYR=R%((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyt__iter__s$ !   !csRtjtd|jjfd}|j|jj|jj S(sreturn the 'count'. Equivalent to :meth:`.Query.count`. Note this uses a subquery to ensure an accurate count regardless of the structure of the original statement. .. versionadded:: 1.1.6 t*cs |jS(N(t from_self(R=(tcol(sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRARf( RtcountRRqR+R0R/RmRrtscalar(R Rq((RsG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRs cCsGy+|j}t|ts"|S|dSWntjk rBdSXdS(sReturn the first element of the first result or None if no rows present. If multiple rows are returned, raises MultipleResultsFound. Equivalent to :meth:`.Query.scalar`. .. versionadded:: 1.1.6 iN(toneR&R'torm_exct NoResultFoundRE(R tret((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRs   cCsg|jjd}t|j|jj|jj|j}t |dkr_|dSdSdS(sLReturn the first row. Equivalent to :meth:`.Query.first`. cSs|jddS(Nii(tslice(R=((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRARfiN( RqR+R!R0R/RmRrRyRsRtRE(R RqR((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytfirsts cCs\y|j}Wn#tjk r5tjdn#X|dkrTtjdn|SdS(seReturn exactly one result or raise an exception. Equivalent to :meth:`.Query.one`. s"Multiple rows were found for one()sNo row was found for one()N(t one_or_noneRtMultipleResultsFoundRER(R R((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRs  cCsOt|}t|}|dkr,|dS|dkr<dStjddS(sReturn one or zero results, or raise an exception for multiple rows. Equivalent to :meth:`.Query.one_or_none`. .. versionadded:: 1.0.9 iis*Multiple rows were found for one_or_none()N(R!RtRERR(R Rtl((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRs    cCs t|S(sEReturn all rows. Equivalent to :meth:`.Query.all`. (R!(R ((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytall scCs,|jjd|j}|j||jS(sZRetrieve an object based on identity. Equivalent to :meth:`.Query.get`. i(RqRR/t _get_implt_load_on_pk_identity(R tidentRL((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRIsc s|jj\fd}j}|j}|jf7_|j|tdD}tgtj D]\}}|j |f^q}t |j j j|}t|} | dkrtjn| r|dSdSdS(s6Load the given primary key identity from the database.cs}|j}|jd|_dkrtgtjD]%\}}|dkrG|j^qG}tj ||}n|j |t t }||_ xjD]}||}qW|S(N(R#t_get_conditionREt _order_bytsettzipt primary_keyRFtsql_utiltadapt_criterion_to_nullt _adapt_clauseR3Rt _criterionRs(RLt_lcl_get_clauseR=RtvaluetnonesR%(t _get_clauset _get_paramstmappertprimary_key_identityR (sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytsetup&s"    " css|]}|dkVqdS(N(RE(t.0telem((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pys NsiiN(t _mapper_zeroRRqR#RR+R'tdictRRRFR!R0R/RmRtRRRE( R RLRRRqtid_valRRmtresultR((RRRRR sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRs&   5!  (RqR/RrRs(RRRRR RmRyRlRJR{RRRRRRRRIR(((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyR.Ys"             s1.2s5Baked lazy loading is now the default implementation.cCsdS(sEnable the use of baked queries for all lazyloaders systemwide. The "baked" implementation of lazy loading is now the sole implementation for the base lazy loader; this method has no effect except for a warning. N((((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytbake_lazy_loadersds cCstddS(sDDisable the use of baked queries for all lazyloaders systemwide. This method now raises NotImplementedError() as the "baked" implementation is the only lazy load implementation. The :paramref:`.relationship.bake_queries` flag may be used to disable the caching of queries on a per-relationship basis. s4Baked lazy loading is now the default implementationN(tNotImplementedError(((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytunbake_lazy_loadersqs cCs|j|idd6S(sxIndicate that the given attribute should be loaded using "lazy" loading with a "baked" query used in the load. t baked_selecttlazy(tset_relationship_strategy(tloadoptRZ((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytbaked_lazyloadssFBaked lazy loading is now the default implementation for lazy loading.cGstjjtjj|tiS(N(Rt _UnboundLoadt _from_keysRR(tkeys((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pyRs cGstjjtjj|tiS(N(RRRRR3(R((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytbaked_lazyload_alls ($RR~tloggingRfRR\RtormRRt orm.queryRt orm.sessionRtsqlRRRt getLoggerRtlogtobjectRRR.t deprecatedRRt loader_optionRt_add_unbound_fnt_add_unbound_all_fnRt _unbound_fnt_unbound_all_fnR(((sG/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/ext/baked.pytsB  #