mò ‹%ÜGc@stdklZdkZdkZdZdefd„ƒYZdfd„ƒYZdefd„ƒYZdd „ZdS( (s spyceModuleNs@Response module provides user control over the browser response.tresponsecBsõtZd„Zd„Zdd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d d „Zd„Zd„Zd„Zd d„Zd„Zd„Zdd„Zdd„Zd d„Zdd„Zd„Zd„ZRS(NcCs=|iƒd|_d|_|ii|iƒ|iƒdS(Ni(tselft clearFilterst _unbuffert_ioerrort_apitregisterResponseCallbackt syncResponse(R((t4/home/holguin2/public_html/spyce/modules/response.pytstarts    cCs|iiƒ|_dS(N(RRt getResponset _response(R((RRscCs2|ii|iƒ|p|iidƒndS(Ni(RRtunregisterResponseCallbackRttheErrort_filtertflush(RR ((RtfinishscCs(t|ƒ|_d|ifg|_dS(Nic(t FilterUnifyRRt _filterList(R((RRsc Cs d}x_tt|iƒƒD]H}|i|\}} ||jo"|i|\} }|i|=PqqW|o'|ii ||fƒ|ii ƒnxXtt|iƒdƒD]=}|i|\} }|i|d\}}|i|ƒq°W|id\} |_|S(sGInject filter functions into output stream at given level of precedenceiiN(tNonet filterExiststrangetlenRRtitlt_tleveltfiltertappendtsorttl1tf1tl2tf2tsetNextR( RRRRRRRR!R RR((Rt addFilters&   cCsdkl}|ƒ‚dS(N(s spyceDone(tspyceExceptiont spyceDone(RR%((Rtend3s cCsOy,|ii|ƒ|io|iƒnWntj od|_nXdS(s"Write out a dynamic (code) string.iN(RRtwritetsRRtIOErrorR(RR(((RR'6s cCs|i|dƒdS(s$Writeln out a dynamic (code) string.s N(RR'R((RR(((Rtwriteln=scCsOy,|ii|ƒ|io|iƒnWntj od|_nXdS(sWrite out a static string.iN(RRt writeStaticR(RRR)R(RR(((RR+@s cKsXy5t|ii|f|ƒ|io|iƒnWntj od|_ nXdS(sWrite out an expression result.iN( tapplyRRt writeExprR(tkwargsRRR)R(RR(R.((RR-Gs cCs|iiƒdS(s1Clear the output buffer. (must not be unbuffered)N(RRtclear(R((RR/NsicCs7y|ii|ƒWntj od|_nXdS(sFlush resident buffer.iN(RRRtstopFlagR)R(RR0((RRQs cCs|ii|ƒdS(s3Set document content type. (must not be unbuffered)N(RR tsetContentTypetct(RR2((RR1WscCs|iit|ƒƒdS(sSet HTTP return (status) codeN(RR t setReturnCodetinttcode(RR5((RR3ZscCs|iS(N(RR(R((Rt isCancelled]scCs=ti|dƒdjo d‚n|ii|||ƒdS(s,Add an HTTP header. (must not be unbuffered)t:iÿÿÿÿs0HTTP header type should not contain ":" (colon).N(tstringtfindttypeRR t addHeadertdatatreplace(RR:R<R=((RR;_s cCs|iiƒdS(s/Clear all HTTP headers (must not be unbuffered)N(RR t clearHeaders(R((RR>dscCs1|iiƒo d‚nd|_|iƒdS(s?Turn off output stream buffering; flush immediately to browser.sAspyce code with parent template may not specify unbuffered outputiN(RRt _hasParentRR(R((Rtunbuffergs   cCs|idt|ƒdƒdS(s*Timestamp response with a HTTP Date headertDateiN(RR;t_genTimestampStringtthetime(RRC((Rt timestampmscCs|idt|ƒdƒdS(sAdd HTTP expiration headerstExpiresiN(RR;RBRC(RRC((RtexpirespscCs!|ittiƒƒ|ƒdS(sDSet response expiration (relative to now) with a HTTP Expires headerN(RRFR4ttimetsecs(RRH((Rt expiresRelssiÿÿÿÿcCs‘|djoL|iiƒ}| ptii|ƒ o d‚nti|ƒd}n|i dt |ƒdƒ|djo|i ƒndS(sSet last modification timeiÿÿÿÿsDrequest filename not found; can not determine last modification timei s Last-ModifiediN( RCRRt getFilenametfilenametostpathtexistststatR;RBRRD(RRCRK((Rt lastModifiedvs   cCs$|iddƒ|iddƒdS(sCEnsure that compliant clients and proxies don't cache this responses Cache-Controls#no-store, no-cache, must-revalidatetPragmasno-cacheN(RR;(R((Rt uncacheable€scCsDg}|idt|iƒƒ|id|iƒti|dƒS(Ns filters: %ssunbuffered: %ss, (R(RRRRRR8tjoin(RR(((Rt__repr__„s(t__name__t __module__R RRRRR#R&R'R*R+R-R/RR1R3R6R;R>R@RDRFRIRPRRRT(((RRs0                      tFiltercBsntZd„Zd„Zd„Zd„Zdd„Zd„Zd„Zd „Z d „Z d „Z d „Z RS( NcCs ||_dS(N(RRtnext(RR((RR"—scCs#|i|ƒ}|ii|ƒdS(N(Rt dynamicImplR(RXR'(RR(((RR'™scCs#|i|ƒ}|ii|ƒdS(N(Rt staticImplR(RXR+(RR(((RR+œscKs5t|i|f|ƒ}t|ii|f|ƒdS(N(R,RtexprImplR(R.RXR-(RR(R.((RR-ŸsicCs|iƒ|ii|ƒdS(N(Rt flushImplRXRR0(RR0((RR¢s cCs|iƒ|iiƒdS(N(Rt clearImplRXR/(R((RR/¥s cOs d‚dS(Nsnot implemented((RR(targsR.((RRY¨scOs d‚dS(Nsnot implemented((RR(R^R.((RRZªscOs d‚dS(Nsnot implemented((RR(R^R.((RR[¬scCs d‚dS(Nsnot implemented((R((RR\®scCs d‚dS(Nsnot implemented((R((RR]°s( RURVR"R'R+R-RR/RYRZR[R\R](((RRW–s          RcBs,tZd„Zd„Zd„Zd„ZRS(NcCs-||_|iii|iƒ|iƒdS(N(tmodRRRR(RR_((Rt__init__´s cCsF|iiiƒ}|i|_|i|_|i|_|i|_dS(N( RR_RR RR'R+RR/(RR((RR¸s    cKs.|djo d}n|it|ƒƒdS(Nt(R(RRR'tstr(RR(R.((RR-¾s  cCsdS(N((RR((RR"Âs(RURVR`RR-R"(((RR³s   cCs†|djottiƒƒ}nt|ƒtdƒjotidti|ƒƒ}nt|ƒtdƒjo|Snd‚dS(sGenerate timestamp stringis%a, %d %b %Y %H:%M:%S %ZRas;thetime value should be None or string or integer (seconds)N(RCRR4RGR:tstrftimet localtime(RC((RRBÅs ( t spyceModuleR8RGt__doc__RRWRRRB(ReRRBRfRWRGRR8((Rt? s ‡