mò +á¸Ec@s»dZdkZdkZdkZdklZlZlZlZl Z dk l Z l Z l Z dklZlZgZdfd„ƒYZdfd„ƒYZd eefd „ƒYZdS( s6$Id: DT_String.py 40317 2005-11-22 15:14:40Z tseaver $N(s ParseErrors InstanceDicts TemplateDicts render_blockssstr(sVarsCallsComment(s ReturnTagsDTReturntStringcBs¾tZdZdZdfd„ƒYZeƒZdBe_de_fe_fZfZ fZ d„Z fZ d„Z fZhd e<d e<d dC<ddD<ddE<ddF<ddG<de<ddH<ddI<ddJ<d"ei?ƒd9„Z@fZAd:„ZBfZCd;„ZDfZEd<„ZFehd=„ZGeZHeZId>„ZJdKdA„ZKRS(Ls9Document templates defined from strings. Document template strings use an extended form of python string formatting. To insert a named value, simply include text of the form: '%(name)x', where 'name' is the name of the value and 'x' is a format specification, such as '12.2d'. To intrduce a block such as an 'if' or an 'in' or a block continuation, such as an 'else', use '[' as the format specification. To terminate a block, ise ']' as the format specification, as in:: %(in results)[ %(name)s %(in results)] it func_codecBstZRS(N(t__name__t __module__(((t9/data/zmath/zope/lib/python/DocumentTemplate/DT_String.pyR.stselftREQUESTicCs|S(N(ts(RR((RterrQuote8scCsEtd||i|ƒt|| idƒƒ|i|i ƒf‚dS(Ns %s, for tag %s, on line %s of %ss ( t ParseErrortmessRRttagtlenttexttstarttsplitR(RR R R R((Rt parse_error;stvartcalltintDT_IntIntwithtDT_WithtWithtiftDT_IftIftunlesstUnlesstelsetElsetcommenttraisetDT_RaisetRaisettrytDT_TrytTrytlettDT_LettLettreturncCstdd|ƒS(NtR(Rtname(RR,((Rt SubTemplateQscCstidtiƒS(Nsj%\((?P[a-zA-Z0-9_/.-]+)([- ]+(?P([^\)"]+("[^"]*")?)*))?\)(?P[0-9]*[.]?[0-9]*[a-z]|[]![])(tretcompiletI(R((RttagreUs R+c Bs²|i|||ƒ\}}}} e|ƒ|jon|\} }} h}yd|| f|UWn%ej od|| f|UnX|| }||i| tKeyErrortVar( RR3R4R5RHR6R R@R,((RR2os( $  6cCs |idƒS(NR@(R3RD(RR3((RtvarExtra˜sic Csó|djo g}n|djo|iƒ}n|i||ƒ} x„| o|| idƒ}y|i | ƒ\} }} } Wn3tj o'}|i|d|d||ƒnX|||!}|o|i|ƒn|t| ƒ}t| dƒo(|i||||| ||| ƒ}n–yc| tjo| ||i| ƒƒ} n | |ƒ} t| dƒo | i} n|i| ƒWn/tj o#}|i|d| ||ƒnX|i||ƒ} qIW||}|o|i|ƒn|S(NiiRGt simple_form(tresultRFR1RtsearchR RtmoRHR?R R6R4R7R tmRRtappendR thasattrt parse_blockRJRKtrRL(RR RRMR1R6RPRHRR R4RTROR7((RtparseœsB  #     s[ ]* cCsG|i||ƒ}|dj o$||idƒ|idƒ}n|S(Ni(teoltmatchR RRORFtend(RR RRVRO((Rtskip_eol¼s $c Cs/|i||ƒ}g} |i} |} |} |}xõ|i||ƒ}|djo|id|||ƒn|idƒ}y%|i|||ƒ\} }}}Wn3tj o'}|i|d|d||ƒnX|oI|t| ƒ}t|dƒo%|i|||| |||ƒ}q&q6|i| ƒ}|i || | ƒ|_!|_d|_"| i#| ||fƒ|i||t| ƒƒ}|o|} | } |}|} q6y:|| ƒ}t|dƒo |i%}n|i#|ƒWn/tj o#}|i|d|||ƒnX|Sq6WdS(NisNo closing tagiRGRL('RRYR RtblockstscommandR,ttnametstagtsnametsstartR5tsaR1RNRORFRtslocRHR?R R6R4R7R RPR RRt parse_closeR-tsectionRUt _v_blockst _v_cookedRQRTRLRM(RR RRMR1R]RaR5R[R R_R\R^RZR6R7RORPRHRTR4R`Rc((RRSÅsN  %#     cCsx|i||ƒ}|djo|id|||ƒn|idƒ} y%|i |||ƒ\} } } }Wn3tj o'} |i| d| d|| ƒnX| t| ƒ}| o9t| dƒo%|i|||| | | | ƒ}qq|p|SqqWdS(NisNo closing tagiRG(R1RNR RRORFRRR]RaRHR?R[R`R R6R4R7R RPR RRRb(RR RR1R]RaR[R`ROR6RPRHR R4R7((RRbös" %#scKs*||_|i||ƒ|i|ƒdS(sÅ Create a document template from a string. The optional parameter, 'mapping', may be used to provide a mapping object containing defaults for values to be inserted. N(t source_stringRtrawtinitvarstmappingtvarstsetNameR(RRfRiRRj((Rt__init__ s cCs|iS(N(RR(R((RR,scCs||idtSubTemplate__roles__R-ttagre__roles__R1t_parseTag__roles__RFR8R?tparseTag__roles__R2tvarExtra__roles__RKtparse__roles__RUtskip_eol__roles__R.R/RYtparse_block__roles__RStparse_close__roles__Rbtshared_globals__roles__RRlR,tidtsetName__roles__Rktdefault__roles__Rst var__roles__Rtmunge__roles__Rvtmanage_edit__roles__Rxtread_raw__roles__Ryt read__roles__Rzt cook__roles__tthreadt allocate_lockRutinitvars__roles__Rht'ZDocumentTemplate_beforeRender__roles__R‚t&ZDocumentTemplate_afterRender__roles__RƒR›RŽRRœR¡(((RRs‚       r   (  0             { t FileMixincBs/tZdZdddd„ZfZd„ZRS(NR+cKs1||_|i||ƒ|i|p|ƒdS(sÍ Create a document template based on a named file. The optional parameter, 'mapping', may be used to provide a mapping object containing defaults for values to be inserted. N(t file_nameRRgRhRiRjRkR(RRÈRiRRj((RRløs cCsc|io |iSntii|iƒpd|iGHn|iot|idƒiƒSndS(Nsfile not found: %sRTR+(Rt edited_sourcetostpathtexistsRgtopenRz(R((RRys  (RRRÉRFRlR¿Ry(((RRÇôs tFilecBstZdZfZd„ZRS(s? Document templates read from files. If the object is pickled, the file name, rather than the file contents is pickled. When the object is unpickled, then the file will be re-read to obtain the string. Note that the file will not be read until the document template is used the first time. cCs td‚dS(Nscannot edit files(t TypeError(RRw((RRxs(RRR¢R¾Rx(((RRÎ s (R¢RÊRÂR.tDT_UtilR R•R‰R˜tstrtDT_VarRJR¬R­t DT_ReturnR®R™R–RRÇRÎ(R­R™RÑRÂRÎR®RÇR–R R.R˜R•R‰RJR¬RÊR((Rt? s   %ÿÜ