mò +á¸Ec@sádZdZddd!ZdklZdkZdkZdkZdkl Z l Z l Z l Z dk lZlZlZlZd klZd klZd klZd klZlZd klZdklZdfd„ƒYZdfd„ƒYZdhd„Z dhd„Z!dhd„Z"dhd„Z#dhd„Z$dhd„Z%dhd„Z&dhei'dƒi(d„Z)dhd„Z*dhd„Z+dhd„Z,dhd „Z-dhd!„Z.dhd"„Z/dhd#„Z0hd$e%<d%e&<d&e,<d'e/<d(e.<d)e0<d*e<d+e <d,e!<d-e"<d.e#<d/e$<d0e)<d1e*<d2e+ Inserts the result of calling the method 'DayOfWeek' of the object bound to the variable 'date', with no arguments. In addition to object methods, serveral additional custom formats are available: 'whole-dollars' -- Show a numeric value with a dollar symbol. 'dollars-and-cents' -- Show a numeric value with a dollar symbol and two decimal places. 'collection-length' -- Get the length of a collection of objects. Note that when using the EPFS source format, both a C-style and a custom format may be provided. In this case, the C-Style format is applied to the result of calling the custom formatting method. Null values and missing variables In some applications, and especially in database applications, data variables may alternate between "good" and "null" or "missing" values. A format that is used for good values may be inappropriate for null values. For this reason, the 'null' parameter can be used to specify text to be used for null values. Null values are defined as values that: - Cannot be formatted with the specified format, and - Are either the special Python value 'None' or are false and yield an empty string when converted to a string. For example, when showing a monitary value retrieved from a database that is either a number or a missing value, the following variable insertion might be used:: Missing values are providing for variables which are not present in the name space, rather than raising an NameError, you could do this: and in this case, if cost was missing, it would be set to 0. In the case where you want to deal with both at the same time, you can use 'default': In this case, it would use '' if the value was null or if the variable was missing. String manipulation A number of special attributes are provided to transform the value after formatting has been applied. These parameters are supplied without arguments. 'lower' -- cause all upper-case letters to be converted to lower case. 'upper' -- cause all upper-case letters to be converted to lower case. 'capitalize' -- cause the first character of the inserted value to be converted to upper case. 'spacify' -- cause underscores in the inserted value to be converted to spaces. 'thousands_commas' -- cause commas to be inserted every three digits to the left of a decimal point in values containing numbers. For example, the value, "12000 widgets" becomes "12,000 widgets". 'html_quote' -- convert characters that have special meaning in HTML to HTML character entities. 'url_quote' -- convert characters that have special meaning in URLS to HTML character entities using decimal values. 'url_quote_plus' -- like url_quote but also replace blank space characters with '+'. This is needed for building query strings in some cases. 'url_unquote' -- convert HTML character entities in strings back to their real values. 'url_unquote_plus' -- like url_unquote, but also replace '+' characters with spaces. 'sql_quote' -- Convert single quotes to pairs of single quotes. This is needed to safely include values in Standard Query Language (SQL) strings. 'newline_to_br' -- Convert newlines and carriage-return and newline combinations to break tags. 'url' -- Get the absolute URL of the object by calling it's 'absolute_url' method, if it has one. Truncation The attributes 'size' and 'etc' can be used to truncate long strings. If the 'size' attribute is specified, the string to be inserted is truncated at the given length. If a space occurs in the second half of the truncated string, then the string is further truncated to the right-most space. After truncation, the value given for the 'etc' attribute is added to the string. If the 'etc' attribute is not provided, then '...' is used. For example, if the value of spam is '"blah blah blah blah"', then the tag '' inserts '"blah blah ..."'. Evaluating expressions without rendering results A 'call' tag is provided for evaluating named objects or expressions without rendering the result. s7$Id: DT_Var.py 41185 2006-01-07 14:34:38Z andreasjung $s$Revision: 1.60 $i iþÿÿÿ(sescapeN(squotes quote_plussunquotes unquote_plus(s parse_paramss name_paramsstrsustr(s html_quote(saq_base(s TaintedString(sHTMLWithImagessHTML(sDocumentWithImages(sgetConfigurationtVarcBs/tZdZdZdd„Zd„ZeZRS(Ntvartsc*CsÍ|d djo|d}nt|ddddddddd dd dd dd d ddddddddddddddddddddddddƒ}||_ttd„t||id„tƒƒƒ|_t|ddƒ\}}|||_ |_ ||_ t |ƒdjo@|d jo3|djo |}n |i}d|f|_ngt |ƒd joS|d joF|idƒo6|djo |}n |i}d|d!f|_ndS("Nisvar tnamettlowerituppertexprt capitalizetspacifytnulltfmtRtsizeitetcs...tthousands_commast html_quotet url_quotet sql_quoteturl_quote_plust url_unquoteturl_unquote_plustmissingt newline_to_brturlcCs|dS(Ni(tt(R((t6/data/zmath/zope/lib/python/DocumentTemplate/DT_Var.pyt¹scCs||dƒo ||dS(Ni(tusedtmtargs(RRR((RRºsRtvith(Rt parse_paramstselfttupletmaptfilterthas_keyt modifierst name_paramRRt__name__R tlentNonetevalt simple_form(R!RR RR((Rt__init__­s4        0  cCs|i}|i}|i}|i}|djos|i|ƒo=|dƒo"|i |dƒ}|i ƒ}q ||}qÐ|dƒo |dSqÐt |‚n-|i |ƒ}|dƒo|i ƒ}n|||f}|dƒo!| o|djo |dSn|dƒoDt|ddƒ}|djo t}n|d}|dƒoJ| oB|djo5yºt||ƒo|||ƒƒ}n‘ti|ƒo;|djot|tƒoq(t||||ƒ}nF|djo d}n/t|tƒot||ƒ}n ||}WqZtiti} } ttd ƒotiƒd \} } n|djpt|ƒ o |dSn| | ‚qZXq^t||ƒo|||ƒƒ}q^ti|ƒo;|djot|tƒoqZt||||ƒ}q^|djo d}q^t|tƒot||ƒ}q^||}n|i}|d jo$t|tƒpt|ƒ}qðnYd} t|tƒo d } nd |i|f}| od|jot|ƒ}nxD|iD]9} | idjot|tƒoqún| |ƒ}qúW|dƒo¯|d}yt"|ƒ}Wnt#d‚nXt$|ƒ|jok|| }|i%dƒ} | |d jo|| d  }n|dƒo|d} nd} || }qónt|tƒo|i'ƒ}n|S(NRiRR R tguarded_getattrs html-quoteRtexc_infoiRit%tsize attribute was used in a var tag with a non-integer value.t R s...((R!RR%thave_argR(RRtvalR*tmdtgetitemt absolute_urltKeyErrorR+t__traceback_info__tgetattrt_getR thasattrtspecial_formatst isinstancet TaintedStringtsystexc_typet exc_valueRRR/tstrtustrt wastaintedR&tfR tintt ValueErrorR)trfindtltquoted(R!R5R R4RR9R3RR;RFRJRERRR ((RtrenderÌs°          "     "             (R(t __module__RR*RR-RLt__call__(((RR©s   ztCallcBstZdZdZd„ZRS(NtcallcCsft|ddddƒ}t|ddƒ\}}|djo |}n |i}d|df|_dS(NRRRRPiti( R RR'RRR*R+R!R,(R!RRR((RR-Ls   (R(RMRR*RR-(((RROHss(Unknown name)cCstt|ƒƒS(N(tquoteRCR(RRR5((RRTscCstt|ƒƒS(N(t quote_plusRCR(RRR5((RRWscCstt|ƒƒS(N(tunquoteRCR(RRR5((RRZscCstt|ƒƒS(N(t unquote_plusRCR(RRR5((RR]scCs”t|tƒo|iƒ}nt|ƒ}|idƒdjodi|idƒƒ}n|idƒdjodi|idƒƒ}n|S(Ns iRs s
(R>RR?RKRDtfindtjointsplit(RRR5((RR`s cCsy d|SWn dSnXdS(Ns$%dR(R(RRR5((Rt whole_dollarsis cCsy d|SWn dSnXdS(Ns$%.2fR(R(RRR5((Rtdollars_and_centsms s ([0-9])([0-9][0-9][0-9]([,.]|$))cCsÁt|ƒ}|idƒ}|p|Sn|d}|d=|oddi|ƒ}nd}||ƒ}xK|dj o=|i dƒ}||d d||d}||ƒ}qnW||S(Nt.iRit,( RCRRXtvlRWRtthoutmoR*tstartRJ(RRR5R^R_R]RJR((RRqs     cCs(yd|}Wn d}nXt|ƒS(Ns$%dR(RR(RRR5((Rtwhole_dollars_with_commas‚s  cCs(yd|}Wn d}nXt|ƒS(Ns$%.2fR(RR(RRR5((Rtdollars_and_cents_with_commas‡s  cCstt|ƒƒS(N(RCR)R(RRR5((Rt len_formatŒscCsttt|ƒƒƒS(N(RRCR)R(RRR5((Rt len_commascCsodkl}t|tƒo |}n?t|ƒiddgjot|ƒiƒ}n t|ƒ}||ƒS(N(sHTMLs DTML Documents DTML Method( treStructuredTexttHTMLR>RRCttxttaq_baset meta_typetread_raw(RRR5RgRf((Rtrestructured_text’s   cCs‰t|tƒo |}n?t|ƒiddgjot|ƒiƒ}n t|ƒ}tƒi}t ƒ|ƒ}t ƒ||dt ƒS(Ns DTML Documents DTML Methodtheader(R>RRCRgRhRiRjtgetConfigurationtstructured_text_header_leveltleveltDocumentWithImagestdocRftFalse(RRR5RoRqRg((Rtstructured_text s   cCs.|idƒdjo|iddƒSn|S(s¡Quote single quotes in a string by doubling them. This is needed to securely insert values into sql string literals in templates that generate sql. t'is''N(RRVtreplace(RRR5((RR®ss whole-dollarssdollars-and-centsscollection-lengthsstructured-textsrestructured-texts sql-quotes html-quotes url-quotesurl-quote-pluss url-unquotesurl-unquote-pluss multi-lines comma-numericsdollars-with-commassdollars-and-cents-with-commascCs0|idƒdjo|iddƒ}n|S(Nt_iR2(R4RVRu(R4((RR ËscCs |i|fS(N(RFR((RF((RRÓstCommentcBs5tZdZdZfZdd„Zd„ZeZRS(sÅComments The 'comment' tag can be used to simply include comments in DTML source. For example:: This text is not rendered. tcommentRcCsdS(N((R!RR ((RR-æscCsdS(NR((R!R5((RRLès(R(RMt__doc__RtblockContinuationsR-RLRN(((RRwÕs   (9Ryt __rcs_id__t __version__tcgitescapetstringtreR@turllibRRRSRTRUtDT_UtilR R'RCRDRt AcquisitionRhtZPublisher.TaintedStringR?tzope.structuredtext.htmltHTMLWithImagesRftzope.structuredtext.documentRpt App.configRmRRORRRRRRYRZtcompiletsearchRRaRbRcRdRkRsRR=R RRRR&R#Rw(+RTRdR†RbRRRpROR~RRaRhRURR€RfR R|RyRmRRRRR@RSR&RkRR'R RwRRRDR?R{RcRYRCRZRR=Rs((Rt? sD       Ÿ    9