mò ñƒCc@s8dZdklZdklZdkZdkZdklZl Z dk l Z l Z de fd„ƒYZdklZlZyd klZWnnXyd klZWn eZnXd fd „ƒYZd efd„ƒYZd„Zd„Zd„Zd„Zd„Zd„Zedjo eƒndS(s$Revision: 1.1.1.1 $(smktemp(s StringTypeN(sSessionsCookieFileImpl(sHTTP_MOVED_PERMANENTLYsHTTP_MOVED_TEMPORARILYt SERVER_RETURNcBstZRS(N(t__name__t __module__(((t7/usr/home/thanos/public_html/pso-example/pso/request.pyRs(surlparses urlunparse(s urlencode(sUrlt RequestIOcBs°tZdZdd„Zed„Zd„Zd„Zd„Zdd„Z d „Z d „Z d „Z d „Z d „Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s® RequestIO is a proxy ouput stream. Everything writen to it will be buffered until the headers are sent or complete. Then the contents is flused to the real out stream. iÿÿÿÿcCsdS(Nt((tselftn((Rtread0scCsdS(NR((Rtlength((Rtreadline1scCsgS(N((R((Rt readlines2scCs|idi|ƒƒdS(NR(Rtwritetjointlist(RR((Rt writelines3scCsdS(Ni((R((Rtisatty5sicCsdS(N((Rtpostmode((Rtseek6scCs(d|_d|_d|_d|_dS(NiR(RRt headers_senttouttNonet header_out(R((Rt__init__8s   cCsX|pdSn|ip|i|7_n|iƒi|ƒ|it|ƒ7_dS(N(tsRRRt getOutStreamR Rtlen(RR((RR >s  cCs#|iƒi|iƒd|_dS(NR(RRR R(R((RtflushFscCs-|idjo|iiƒ|_n|iS(N(RRRtimplt getHeadersOut(R((RRKscCs|iS(N(RR(R((RttellPscCs|iƒ|iƒdS(N(Rtsend_http_headerR(R((RtcloseQs cCs d|_dS(Ni(RR(R((Rt headersSentVscCs|iƒdS(N(RR!(R((Rt__del__YscCs7t|ƒtjot|ƒ}n||iƒ|Ÿs   cCs||iƒ|R((RR(R%((Rt setEnviron«scKsx|ojx*|iƒD]\}}|i||ƒqWt||ƒƒ|_|ii ƒo|i |iƒqqn|iS(sî returns the current session. The session implentation class may be passed to sessionImplClass, which if None defaults to CookieFileImpl. The method can be passed keyword arguments which will be treated as HTTP directives N( tsessionImplClasst parameterstitemstktvRRAtSessionR:tisNewt setSession(RRBRCRERF((Rt getSession·s cCs|ii||ƒdS(N(RRRItsession(RRK((RRIÅscCs |iiƒS(N(RRt getCookieKey(R((RRLÏscCss|idjo\|i|iiƒdƒ}|o-dkl}|ƒ|_|ii|ƒqlh|_n|iS(sB req.getCookies()-> dict returns a dictionary of cookies. R(s SmartCookieN( RtcookiesRR>RRLtCookiet SmartCookietload(RRORM((Rt getCookiesÒs   cCs|iƒi||ƒS(so returns the cookie requested by key otherwise returns default, if default is not given returns None. N(RRQR?R(R@(RR(R@((Rt getCookieâscKs[d}|||f}x.|iƒD] \}}||||f7}q#W|i d|ƒdS(s‚ sets cookie, key, to value. Also will set any attributes given. e.g. request.setCookie("login",name, comment="user id") s%s=%s;s set-cookieN( t cookiefmtR(R%tcookietattrsRDRERFRR+(RR(R%RURSRTRFRE((Rt setCookieés s text/htmlcCsœ|iƒidƒpH|iƒidƒp.|iƒidƒp||iƒd 1 | 0 tests if a field in a form was filled. N(Rt getInputsRXR((RR(((RthasInput!scGs<g}|D]*}||iƒiƒjo ||q q ~S(N(t_[1]tkeysR(RR`(RRcRbR(((Rt hasInputs'scCs¼|ip|ii|ƒ|_n|p |iSnt|idƒo|ii|ƒSn]|ii|ƒoE|ii|ƒ}|o!t |ƒt gƒjo|Sq´|gSngSdS(særeq.getInput(key) -> FiledStorage| List of Fields if key is given will return a list of fields values for that key. if there are no values an empty list is returned. if no key is given returns the cgi.FieldStorage object. tgetlistN( RtinputsRR`R(thasattrReRXtgetvalueR%R$(RR(R%((RR`,s    cCsq|ip`g|_xT|iƒiƒD]<}|i|ƒ}x$|D]}|ii||fƒqBWq&Wn|iS(N(RtinputSeqR`RcR(tvaluesR%tappend(RRjR%R(((Rt getInputSeqBs  "cCsQ|ip@h|_x4|iƒiƒD]}|i|ƒ|i| String | default returns the given form field value as a String. If there are multiple values under the same key, it will return the first in the list, unless index is given. If no value is found will return "", unless default is given. iN(tindexRR`R(R@(RR(R@Ro((RtgetInputQs cCs^|i|ƒoJ|iƒ|}|io,d|i_t |i_ t |i_ |SqZn|S(sÍreq.getFile(fieldname)-> Field returns an uploaded file. The filed has the usual cgi.Field members plus filename - the given file name file - the actual file uploaded tempname - is None until keep() is called. the methods: keep() - The file object is a temporay file that will be deleted when the cgi terminates. keep asigns the file a a temp file name. save(name) - This method can be used to save the tempfile under the given name. N( RRaR(R`tfiletfilenameRt __class__ttempnametkeepR;R@(RR(R@Rq((RtgetFileas      cCs4|idjotd|iƒƒ|_n|iS(Ns#http://%(HTTP_HOST)s%(REQUEST_URI)s(Rt_urlRtUrlR>(R((RtgetUrlzscCsÝtp d‚nd|iƒ}tt|ƒƒ}|iddƒ}|d}|o|i |ƒ\}}n|i dƒ}|djo||}|| }n |}d}||d<|id|ƒ|id |ƒ|S( Ns&under mod_python urlparse has problemss#http://%(HTTP_HOST)s%(REQUEST_URI)st PATH_INFORit/iÿÿÿÿii(RxRR>R\Rturlparsetpartst info_pathtpathtsplittdummytrfindtindxtscripttinsert(RRR„RƒR~R\R}R((RturiPartss$     c Ksh} d}xAdD]9}|i|ƒo||||<||=n|d 7}qW|od |d \} } | i| ƒo| | i| ƒq»| g| | ¨stdoseqis%s%s%siis%s%si(R‡RˆspathsscriptR‰RŠR‹(tquerytiR(tkwsRXR}tcleantqsR$R€tquerySeqtmapRERFRktupdateRDRjR%t urlencodettuplet urlunparse( RR}R”R“R•R(R’R–R%RjRFR‘RE((RtbuildUri—sL         icKs+t|iƒƒ}|i|||}|S(N(RRR†R}RœR”R“R\(RR”R“R\R}((Rt serviceUriÃscCs$t|iƒƒ}dt|d ƒS(Ns %s://%s%s/i(RRR†R}Rš(RR}((RtbaseUriÈscCs|iƒ|S(N(RRžtpage(RRŸ((RtpageUriÌscGsltt|ƒ}dtiƒdi|ƒf}ytii |ƒWn#dk }|i d|iƒnXdS(Ns %s: %st Rq( R—R'targsttimetctimeR tposttsyststderrR t tracebackt print_excR(RR¢R¨R¥((RtlogÐs (/RRR-RRfRiRmRMR=R:RR5R6RR7R0R!R3R>RAtCookieFileImplRJRIRKRLRQRRRVR R[R^R_RaRdR`RlRnRpRvRwRyR†RœRRžR Rª(((RR.msV                        ,   cCsr|ipdtƒ|_|iidƒt|idƒ}|i|iiƒƒ|i ƒt|iƒ|_ndS(s8 req.getFile(key).keep() -> file This method is added to file form fields. Files that are uploaded are stored as nameless temporary files. This method allows you to store the file, so it can be processed at a later stage. Calling it replaces the nameless temp file with the new named temp file. itwbN( t fileFieldRttmktempRqRtopentfpR RR!(R­R°((RRuÜs   cCsR|ip(|iƒ|iiƒ|iiƒndk}|i|i|ƒdS(sÙ req.getFile(key).saveAs(somename) -> None This method is added to file form fields. Files that are uploaded are stored as nameless temporary files. This method alows you to store the file with a given name. N( R­RtRuRqRR!tostrenametnewName(R­R³R±((RR;îs    cCso|p tƒ}n|iƒiƒytdcd7