ó aòNc@s)dZddlmZddlZdgZddgZdefd„ƒYZdefd „ƒYZ defd „ƒYZ de fd „ƒYZ d efd „ƒYZ de fd„ƒYZde fd„ƒYZdefd„ƒYZde fd„ƒYZdefd„ƒYZd„Zee_dS(s Middleware to make internal requests and forward requests internally. When applied, several keys are added to the environment that will allow you to trigger recursive redirects and forwards. paste.recursive.include: When you call ``environ['paste.recursive.include'](new_path_info)`` a response will be returned. The response has a ``body`` attribute, a ``status`` attribute, and a ``headers`` attribute. paste.recursive.script_name: The ``SCRIPT_NAME`` at the point that recursive lives. Only paths underneath this path can be redirected to. paste.recursive.old_path_info: A list of previous ``PATH_INFO`` values from previous redirects. Raise ``ForwardRequestException(new_path_info)`` to do a forward (aborting the current request). iÿÿÿÿ(tStringIONtRecursiveMiddlewaretForwardRequestExceptiont RecursionLoopcBseZdZRS(s*Raised when a recursion enters into a loop(t__name__t __module__t__doc__(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR stCheckForRecursionMiddlewarecBseZd„Zd„ZRS(cCs||_||_dS(N(tapptenv(tselfRR ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyt__init__%s cCsŽ|jddƒ}||jjdgƒkrMtd||jdfƒ‚n|jjdgƒ}|j|jjddƒƒ|j||ƒS(Nt PATH_INFOtspaste.recursive.old_path_infosGForwarding loop detected; %r visited twice (internal redirect path: %s)(tgetR Rt setdefaulttappendR(R tenvirontstart_responset path_infot old_path_info((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyt__call__)s (RRR R(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR$s cBs#eZdZdd„Zd„ZRS(s} A WSGI middleware that allows for recursive and forwarded calls. All these calls go to the same 'application', but presumably that application acts differently with different URLs. The forwarded URLs must be relative to this container. Interface is entirely through the ``paste.recursive.forward`` and ``paste.recursive.include`` environmental keys. cCs ||_dS(N(t application(R Rt global_conf((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR AscCs·t|j||ƒ|dˆjdƒd|d<ˆjdƒd|d<|j||ƒS(NR!iR it QUERY_STRING(tsplitR(R RR(turl(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRás(RRR((R)(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR&às((RR&(R"R)(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR%ßscs&dˆf‡fd†ƒY}||ƒS(NtEnvironForwardcseZ‡fd†ZRS(cs|jˆ|ƒS(N(R(R tenviron_R(R(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRês(RRR((R(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR*és((RR*(R"R(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR%ès( t TypeErrortwarningstwarntDeprecationWarningRtstrtobjectthasattrR(R R)RRRR%((R"RR$R)s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR ¬s<              N(RRRR R (((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRZs Pt RecursivecBs/eZd„Zdd„Zd„Zd„ZRS(cCs.||_|jƒ|_||_||_dS(N(Rtcopytoriginal_environtprevious_environR(R RRR((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR ós  cCsô|jjƒ}|r%|j|ƒn|j|d<|jjdƒ}|jdƒr|j|ƒsxtd||fƒ‚|t|ƒd}n|jdƒ s¥t‚d|}||dRR7(t __class__RRR5R(R ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyt__repr__s  N(RRR R RRARG(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR3ñs   RcBseZdZd„ZRS(s  The forwarder will try to restart the request, except with the new `path` (replacing ``PATH_INFO`` in the request). It must not be called after and headers have been returned. It returns an iterator that must be returned back up the call stack, so it must be used like: .. code-block:: python return environ['paste.recursive.forward'](path) Meaningful transformations cannot be done, since headers are sent directly to the server and cannot be inspected or rewritten. cCs&tjdtdƒ|j||jƒS(NsKrecursive.Forwarder has been deprecated; please use ForwardRequestExceptioni(R-R.R/RR(R R((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRA.s (RRRRA(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRsRcBseZdZd„ZRS(s§ Starts another request with the given path and adding or overwriting any values in the `extra_environ` dictionary. Returns an IncludeResponse object. cs}tƒ‰d‡fd†}|j||ƒ}z"x|D]}ˆj|ƒq7WWdt|dƒrn|jƒnXˆjƒˆS(Ncs:|r!|d|d|d‚n|ˆ_|ˆ_ˆjS(Niii(tstatustheaderstwrite(RHRItexc_info(tresponse(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR@s   tclose(tIncludedResponseR RRJR2RM(R RRtapp_iterts((RLs@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRA>s   (RRRRA(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR6sRNcBsAeZd„Zd„Zd„Zd„Zd„ZeeƒZRS(cCs+d|_d|_tƒ|_d|_dS(N(R RIRHRtoutputR0(R ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR Rs   cCs,|jjƒ|_|jjƒd|_dS(N(RQtgetvalueR0RMR (R ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRMXs cCs/|jdk stdƒ‚|jj|ƒdS(NsIThis response has already been closed and no further data can be written.(RQR R?RJ(R RP((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRJ]s cCs|jS(N(tbody(R ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyt__str__cscCs'|jdkr|jjƒS|jSdS(N(R0R RQRR(R ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyt body__getfs ( RRR RMRJRTRUtpropertyRS(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRNPs      RcBseZdZd„ZRS(sk Like Includer, but just stores the app_iter response (be sure to call close on the response!) cs:tƒ‰d‡fd†}|j||ƒ}|ˆ_ˆS(Ncs:|r!|d|d|d‚n|ˆ_|ˆ_ˆjS(Niii(RHRIRJ(RHRIRK(RL(s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRvs   (tIncludedAppIterResponseR RRO(R RRRO((RLs@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRAts   (RRRRA(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRnsRWcBs#eZd„Zd„Zd„ZRS(cCs1d|_d|_g|_d|_t|_dS(N(R RHRIt accumulatedROtFalset_closed(R ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyR ‚s     cCs<|j stdƒ‚t|jdƒr8|jjƒndS(NsTried to close twiceRM(RZR?R2RORM(R ((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRM‰s  cCs|jjdS(N(RXR(R RP((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRJs(RRR RMRJ(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyRW€s  cCs t|ƒS(N(R(RR((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pytmake_recursive_middleware’s(Rt cStringIORR-t__all__t __pudge_all__R?RR1RRt ExceptionRR3RRRNRRWR[(((s@/opt/alt/python27/lib/python2.7/site-packages/paste/recursive.pyts    %—*