m +Ec@sdZdklZlZdkZdkZdklZlZdfdYZdeifdYZ de fd YZ d ee fd YZ dS( sYHTML formated DocumentTemplates $Id: DT_HTML.py 40218 2005-11-18 14:39:19Z andreasjung $(sStrings FileMixinN(s ParseErrorsstrt dtml_re_classcBsntZdZdeidieideiieidieididZdZdZ RS( s; This needs to be replaced before 2.4. It's a hackaround. is[- ]*[a-zA-Z]+[- ]*s [- ]*(/|end)s[<&]s[-a-zA-Z0-9_.]+cCsx|||}|djodSn|id}|||d!djo|d} |id| }|djodSnd}||| }|dj oA|i d|id} || | | !i } | | } qd} n|||d!d jow|d}} xV|id |d}|djodSnt|| |!id d oPqqWd}d} n|||d !djow|d }} xV|id |d}|djodSnt|| |!id d oPqqWd}d} n|||d!djo||ddjo|d} |id| }|djo|| |!} t| } || }|dj oX|i d|id| jo1|i} ||ddjo`d| d<| ditist"iis HTML document templates quote HTML tags in source when the template is converted to a string. This is handy when templates are inserted into HTML editing forms. cCstS(N(R(R((R%ttagresRc CsZ|idddd\}}}}|i}|o?| p||ijotd|fn||d d fSn|o||i jo|djoh|oat |}||jp&||| jo|||d!djp|||i|d fSqn||d |fSny|||i|d fSWn"tj otd |fnXd S( sParse a tag using an already matched re Return: tag, args, command, coname where: tag is the tag, args is the tag's argument string, command is a corresponding command info structure if the tag is a start tag, or None otherwise, and coname is the name of a continue tag (e.g. else) or None otherwise iRR R sunexpected end tagtelseis sUnexpected tagN(tmatch_obR*ttagRR R Rtcommandt ParseErrorRtblockContinuationsRRtsargsRtcommandstKeyError( RR5R7R:RRR R6R ((R%tparseTags" $  6cCstdd|S(NRR+(R2R (RR ((R%t SubTemplatescCsdS(NR((RR5((R%tvarExtrascCs,|i||o|i||SndS(sedit a templateN(RtmungetdatatREQUESTteditConfirmation(RRARB((R%t manage_edits t&s&t\}}|i|djo|i|i |}q$q$W|S(Ni( RRRtread_rawtcharacter_entitiesR.R RtjoinR(RRRHR R.((R%t quotedHTMLs   cCs |iS(N(RRJ(R((R%t__str__scCs|S(s\Hook to allow public execution of management interface with everything else private.N(R(R((R%tmanagement_interfacescCs%|i|d|dt|d|S(s!Display doc template editing formtmappingRKtURL1N(Rt_manage_editFormRBtstrRN(RRNRB((R%tmanage_editForms   (REs&(RFs<(Rs>(Rs"(R+R,R-ttagre__roles__R3tparseTag__roles__RR=tSubTemplate__roles__R>tvarExtra__roles__R?tmanage_edit__roles__RDtquotedHTML__roles__RJterrQuote__roles__terrQuoteRKtmanagement_interface__roles__RLtmanage_editForm__roles__RQtmanage_editDocument__roles__tmanage__roles__tmanage_editDocumenttmanage(((R%R2s.  #       t HTMLDefaultcBs)tZdZfZeZfZdZRS(s HTML document templates that edit themselves through copy. This is to make a distinction from HTML objects that should edit themselves in place. cCsP|i||i|i}t|d||i dd||i ||S(sedit a templateiRN( Rt copy_classRAtglobalsR+tnewHTMLtsetattrtPARENTSRNtrfindRCRB(RRAReRNRBRc((R%RDs%(R+R,R-tcopy_class__roles__R2RaRVRD(((R%R`s tHTMLFilecBsctZdZfZedZfZdZfZfZ eZ Z fZ gdddddZ RS(sD HTML 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. cCsE|iod|_|i|_n|o|i||SndS(sRevert to factory defaultsRN(Rt edited_sourcetcookt _v_cookedRBRC(RRB((R%tmanage_default s   cCsL|id|d|id|id|id|id|dt|dt S( s!Display doc template editing formRMtdocument_template_edit_widthtdocument_template_edit_headertdocument_template_form_headertdocument_template_edit_footerRNRKtFactoryDefaultStringN( RRORBRmRnRoRpRNRPRq(RRNRB((R%RQs      Rc Cs|tjo|i|Sn|ido4di|id}di|id}n|i o||_ |i |_ nW|i }|i }|i|i||_ t|d||idd||o|i||SndS(sedit a templates s s s iRN(tSUBMITRqRRlRBRARRIRRiRjRkt __class__t__traceback_info__Rct __setstate__t __getstate__RdReRNRfRC( RRAReRNtURL2RBRrRtRc((R%RD*s       %(R+R,R-tmanage_default__roles__RRlR[RQR\R]R^R_RVRD(((R%Rhs    ( R-t DT_StringtStringt FileMixinR.tDT_UtilR8RPRR2R`Rh( RyRzR`RhR{R8R.R2RRP((R%t?sol