ÿØÿà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Áß_ÿÙ aNc @sdZddlZddlmZmZddlmZddlZddlZyddlm Z Wn!e k rddl m Z nXddl m Z ddd d d d d ddg ZdZdZdZdZedZeeddddZdZdZdZidd6dd6dd6ZdZde fd YZd!Zeej_e d"krddl!Z!e!j"ndS(#s This module provides helper routines with work directly on a WSGI environment to solve common requirements. * get_cookies(environ) * parse_querystring(environ) * parse_formvars(environ, include_get_vars=True) * construct_url(environ, with_query_string=True, with_path_info=True, script_name=None, path_info=None, querystring=None) * path_info_split(path_info) * path_info_pop(environ) * resolve_relative_url(url, environ) iN(t SimpleCookiet CookieError(tStringIO(t DictMixin(t MultiDictt get_cookiestget_cookie_dicttparse_querystringtparse_formvarst construct_urltpath_info_splitt path_info_poptresolve_relative_urltEnvironHeaderscCs|jdd}|jdrD|d\}}||krD|Snt}y|j|Wntk rqnX||f|d<|S(s Gets a cookie object (which is a dictionary-like object) from the request environment; caches this value in case get_cookies is called again for the same request. t HTTP_COOKIEts paste.cookies(tgetthas_keyRtloadR(tenvirontheadertcookiest check_header((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR#s   cCs|jd}|siS|jdrK|d\}}||krK|Snt}y|j|Wntk rxnXi}x|D]}||j||/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR7s"    cCsz|jdd}|sgSd|krK|d\}}||krK|Sntj|dtdt}||f|d<|S(s< Parses a query string into a list like ``[(name, value)]``. Caches this value in case parse_querystring is called again for the same request. You can pass the result to ``dict()``, but be aware that keys that appear multiple times will be lost (only the last value will be preserved). t QUERY_STRINGRspaste.parsed_querystringtkeep_blank_valueststrict_parsing(Rtcgit parse_qsltTruetFalse(Rtsourcetparsedt check_source((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyRQs    cCs|jdd}|stSd|krN|d\}}||krN|Sntj|dtdt}t|}||f|d<|S(sParses a query string like parse_querystring, but returns a MultiDict Caches this value in case parse_dict_querystring is called again for the same request. Example:: >>> environ = {'QUERY_STRING': 'day=Monday&user=fred&user=jane'} >>> parsed = parse_dict_querystring(environ) >>> parsed['day'] 'Monday' >>> parsed['user'] 'fred' >>> parsed.getall('user') ['fred', 'jane'] RRspaste.parsed_dict_querystringRR(RRRRRR (RR!R"R#tmulti((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pytparse_dict_querystringhs    cCs,|d}d|krU|d\}}||krU|rN|jt|n|Sn|jddj}d|kr|jddd}n|dk}|jd sd |d /opt/alt/python27/lib/python2.7/site-packages/paste/request.pyRsX                     c Cs|dd}|jdr|d}d}d|kr|jdd\}}|ddkry|dkrd}qq|ddkr|d krd}qqn||7}|r3|d |7}q3nk||d 7}|ddkr|d dkr3|d|d 7}q3n%|d d kr3|d|d 7}n|dkra|tj|jd d7}n|tj|7}|r|dkr|tj|jdd7}q|tj|7}n|r|dkr|jdr|d|d7}qq|r|d|7}qn|S(sReconstructs the URL from the WSGI environment. You may override SCRIPT_NAME, PATH_INFO, and QUERYSTRING with the keyword arguments. swsgi.url_schemes://t HTTP_HOSTt:ithttpst443thttpt80s:%st SERVER_NAMEt SERVER_PORTt SCRIPT_NAMERt PATH_INFORt?N(RtNoneR-turllibtquote( Rtwith_query_stringtwith_path_infot script_namet path_infot querystringturlthosttport((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR sF       " " cCs"t|dt}tj||S(s  Resolve the given relative URL as being relative to the location represented by the environment. This can be used for redirecting to a relative path. Note: if url is already absolute, this function will (intentionally) have no effect on it. RL(R R turlparseturljoin(RQRtcur_url((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR s cCsx|s dS|jds)td||jd}d|krj|jdd\}}|d|fS|dfSdS(s Splits off the first segment of the path. Returns (first_part, rest_of_path). first_part can be None (if PATH_INFO is empty), '' (if PATH_INFO is '/'), or a name without any /'s. rest_of_path can be '' or a string starting with /. Rt/s!PATH_INFO should start with /: %riN(NR(RIt startswithtAssertionErrortlstripR-(ROtfirsttrest((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR s  cCs|jdd}|sdSx-|jdrK|dcd7<|d}qWd|krv|dc|7>> def call_it(script_name, path_info): ... env = {'SCRIPT_NAME': script_name, 'PATH_INFO': path_info} ... result = path_info_pop(env) ... print 'SCRIPT_NAME=%r; PATH_INFO=%r; returns=%r' % ( ... env['SCRIPT_NAME'], env['PATH_INFO'], result) >>> call_it('/foo', '/bar') SCRIPT_NAME='/foo/bar'; PATH_INFO=''; returns='bar' >>> call_it('/foo/bar', '') SCRIPT_NAME='/foo/bar'; PATH_INFO=''; returns=None >>> call_it('/foo/bar', '/') SCRIPT_NAME='/foo/bar/'; PATH_INFO=''; returns='' >>> call_it('', '/1/2/3') SCRIPT_NAME='/1'; PATH_INFO='/2/3'; returns='1' >>> call_it('', '//1/2') SCRIPT_NAME='//1'; PATH_INFO='/2'; returns='1' RGRRWRFiN(RRIRXR-(Rtpathtsegment((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR s  t AuthorizationtHTTP_CGI_AUTHORIZATIONsContent-LengthR(s Content-TypeR&ccsrxk|jD]]\}}|tkr7t||fVq |jdr |djjdd|fVq q WdS(s Parse the headers in the environment (like ``HTTP_HOST``) and yield a sequence of those (header_name, value) tuples. tHTTP_it_t-N(t iteritemst_parse_headers_specialRXttitletreplace(Rtcgi_varR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt parse_headersHs  cBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( sgAn object that represents the headers as present in a WSGI environment. This object is a wrapper (with no internal state) for a WSGI request object, representing the CGI-style HTTP_* keys as a dictionary. Because a CGI environment can only hold one value for each key, this dictionary is single-valued (unlike outgoing headers). cCs ||_dS(N(R(tselfR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt__init___scCsJd|jddj}|dkr1d}n|dkrFd}n|S(NRaRcRbtHTTP_CONTENT_LENGTHR(tHTTP_CONTENT_TYPER&(Rgtupper(RjRtkey((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt _trans_namebs     cCsQ|dkrdS|dkr dS|jdrI|djddjSdSdS( NR&s Content-TypeR(sContent-LengthRaiRbRc(RXRgRfRI(RjRo((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt _trans_keyjs  cCs|j|j|S(N(RRp(Rjtitem((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt __getitem__tscCs||j|j|/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt __setitem__wscCs|j|j|=dS(N(RRp(RjRr((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt __delitem__{sccs;x4|jD])}|j|}|dk r |Vq q WdS(N(RRqRI(RjRoR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt__iter__~s cCstt|S(N(R0titer(Rj((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR1scCs|j||jkS(N(RpR(RjRr((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt __contains__s( t__name__t __module__t__doc__RkRpRqRsRtRuRvR1Rx(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyR Ts        cCs7|jrd|j|jfSd|j|j|jfS(s monkey patch for FieldStorage.__repr__ Unbelievely, the default __repr__ on FieldStorage reads the entire file content instead of being sane about it. This is a simple replacement that doesn't do that sFieldStorage(%r, %r)sFieldStorage(%r, %r, %r)(tfileRR2R(Rj((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pyt_cgi_FieldStorage__repr__patchs  t__main__(#R{RtCookieRRRRTRJtUserDictRt ImportErrortpaste.util.UserDict24tpaste.util.multidictRt__all__RRRR%RRRIR R R R ReRiR R}R.t__repr__Rytdoctestttestmod(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/request.pytsD          @1  (  6