Ñò ô†³Kc @s£dZddklZyddkZWn#ej oddklZnXddklZddk Z ddk Z dgZ de fd„ƒYZ dd „ZdS( s… Middleware that tests the validity of all generated HTML using the `WDG HTML Validator `_ i˙˙˙˙(tStringION(t subprocess24(twsgilibtWDGValidateMiddlewarecBsMeZdZeideiƒZddd„Zd„Z d„Z d„Z RS(sb Middleware that checks HTML and appends messages about the validity of the HTML. Uses: http://www.htmlhelp.com/tools/validator/ -- interacts with the command line client. Use the configuration ``wdg_path`` to override the path (default: looks for ``validate`` in $PATH). To install, in your web context's __init__.py:: def urlparser_wrap(environ, start_response, app): return wdg_validate.WDGValidateMiddleware(app)( environ, start_response) Or in your configuration:: middleware.append('paste.wdg_validate.WDGValidateMiddleware') stvalidatecCs||_||_dS(N(tapptwdg_path(tselfRt global_confR((s</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pyt__init__(s c s”tƒ‰g‰d‡‡‡fd†}|i||ƒ}z"x|D]}ˆi|ƒqCWWdt|dƒo|iƒnXˆiƒ}ˆ\}}ti|dƒpd} | i dƒ o*| i dƒ o| i dƒ o|gSg} | i dƒo| i d ƒn|i |i | |ƒ} | o^|i || ƒd }|id tti|d ƒƒfƒ|i d tt|ƒƒfƒn|gS( Ncs*ˆi||fƒˆ|||ƒˆiS(N(textendtwrite(tstatustheaderstexc_info(tstart_responsetoutputtresponse(s</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pytwriter_start_response0stcloses content-typets text/htmls text/xhtmlsapplication/xhtmlstext/xhtml+xmls--xmlisContent-Lengthscontent-length(RtNoneRR thasattrRtgetvalueRt header_valuet startswithtappendtcall_wdg_validateRt add_errortremovetstrtlen( RtenvironRRtapp_itertstpageR R tvtopst html_errors((RRRs</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pyt__call__,s:   #c Cs{tdjotdƒ‚nti|g|dtdtdtidtidtiƒ}|i|ƒd}|i ƒ|S(Ns>This middleware requires the subprocess module from Python 2.4tshellt close_fdststdouttstdintstderri( t subprocessRt ValueErrortPopentFalsetTruetPIPEtSTDOUTt communicatetwait(RRR%R#tprocR*((s</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pyRSs      cCs_dti|ƒ}|ii|ƒ}|o$||iƒ |||iƒgS||gSdS(NsR
%s
(tcgitescapet_end_body_regextsearchtstart(Rt html_pageR&tadd_texttmatch((s</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pyRbs $N( t__name__t __module__t__doc__tretcompiletIR9RR R'RR(((s</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pyRs  ' RcCst||d|ƒS(s Wraps the application in the WDG validator from http://www.htmlhelp.com/tools/validator/ Validation errors are appended to the text of each page. You can configure this by giving the path to the validate executable (by default picked up from $PATH) R(R(RRR((s</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pytmake_wdg_validate_middlewarens (RAt cStringIORR-t ImportErrort paste.utilRtpasteRRBR7t__all__tobjectRRE(((s</usr/lib/python2.6/site-packages/paste/debug/wdg_validate.pyts   \