Ñò †°Ic@sdZddkZddkZddklZlZdddddd gZeeeeee eeeed e e d „ Z de fd „ƒYZ d „Z d„Zd„Zd„Zd„Zd efd„ƒYZhe d6ed6ed6ed6ed6ZdS(sL Parser for HTML forms, that fills in defaults and errors. See ``render``. iÿÿÿÿN(tRewritingParsert html_quotetrendert htmlliteraltdefault_formattertnone_formattertescape_formattert FillingParserterrorcCs§|d jo h}n|o|d jo t}ntd|d|d|d|d|d|d|d| d | d | d | d | ƒ }|i|ƒ|iƒ|iƒS(s Render the ``form`` (which should be a string) given the defaults and errors. Defaults are the values that go in the input fields (overwriting any values that are there) and errors are displayed inline in the form (and also effect input classes). Returns the rendered string. If ``auto_insert_errors`` is true (the default) then any errors for which ```` tags can't be found will be put just above the associated input field, or at the top of the form if no field can be found. If ``use_all_keys`` is true, if there are any extra fields from defaults or errors that couldn't be used in the form it will be an error. ``error_formatters`` is a dictionary of formatter names to one-argument functions that format an error into HTML. Some default formatters are provided if you don't provide this. ``error_class`` is the class added to input fields when there is an error for that field. ``add_attributes`` is a dictionary of field names to a dictionary of attribute name/values. If the name starts with ``+`` then the value will be appended to any existing attribute (e.g., ``{'+class': ' important'}``). ``auto_error_formatter`` is used to create the HTML that goes above the fields. By default it wraps the error message in a span and adds a ``
``. If ``text_as_default`` is true (default false) then ```` will be treated as text inputs. ``listener`` can be an object that watches fields pass; the only one currently is in ``htmlfill_schemabuilder.SchemaBuilder`` ``encoding`` specifies an encoding to assume when mixing str and unicode text in the template. ``prefix_error`` specifies if the HTML created by auto_error_formatter is put before the input control (default) or after the control. ``force_defaults`` specifies if a field default is not given in the ``defaults`` dictionary then the control associated with the field should be set as an unsuccessful control. So checkboxes will be cleared, radio and select controls will have no value selected, and textareas will be emptied. This defaults to ``True``, which is appropriate the defaults are the result of a form submission. tdefaultsterrorst use_all_keysterror_formatterstadd_attributestauto_error_formatterttext_as_defaulttlistenertencodingt prefix_errort error_classtforce_defaultsN(tNoneRRtfeedtclosettext(tformR R R R R tauto_insert_errorsRRRRRRRtp((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRs$9        cBs/eZdd„Zd„Zd„Zd„ZRS(cCsr|djoOtidd|ƒ}|iddƒ}|iddƒ}|iddƒ}n||_||_dS( Ns<.*?>ts>t>s<t(t __class__t__name__R#R(R$((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyt__repr__kscCs|iS(N(R#(R$((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyt__html__osN(R(t __module__RR%R&R)R*(((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyR\s  cCsdt|ƒS(s{ Formatter that escapes the error, wraps the error in a span with class ``error-message``, and adds a ``
`` s,%s
(R(R((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRrscCs|S(s@ Formatter that does nothing, no escaping HTML, nothin' ((R((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRyscCs t|ƒS(s/ Formatter that escapes HTML, no more. (R(R((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRscCs"t|ƒ}|iddƒ}|S(sJ Formatter that escapes HTML, and translates newlines to ``
`` s s
(RR"(R((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pytescapenl_formatter…s cCsdS(s@ Formatter that emits nothing, regardless of the error. R((R((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pytignore_formattersc BsìeZdZdZdedddddedeed„ Zd„Zd„Z d„Z d„Z ed„Z d „Z d „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s» Fills HTML with default values, as in a form. Examples:: >>> defaults = {'name': 'Bob Jones', ... 'occupation': 'Crazy Cultist', ... 'address': '14 W. Canal\nNew Guinea', ... 'living': 'no', ... 'nice_guy': 0} >>> parser = FillingParser(defaults) >>> parser.feed('\ ... \ ... \ ... ') >>> parser.close() >>> print parser.text() # doctest: +NORMALIZE_WHITESPACE tutf8Rc CsAti|ƒd|_d|_d|_||_d|_t|_ d|_ d|_ t|_ |ph|_ t|i ttfƒoh|i d6|_ nd|_t|_||_h|_h|_|djo t|_n ||_||_|ph|_||_||_| |_| |_| |_| |_dS(N( RR%Rtsourcetlinest source_posR t in_textareatFalset skip_textareatlast_textarea_namet in_selectt skip_nextR t isinstancetstrtunicodetin_errort skip_errorR t used_keyst used_errorstdefault_formatter_dictR RR RRRRRR( R$R R R R RR RRRRRR((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyR%·s:                        cCsºt|tƒp0t|dƒot|ƒ}q@t|ƒ}nt|ƒt|ƒjo ||jSt|tƒo |i|ip|iƒ}n|i|ip|iƒ}||jS(s‹ Compare the two objects as strings (coercing to strings if necessary). Also uses encoding to compare the strings. t __unicode__( R8t basestringthasattrR:R9ttypetencodeRtdefault_encoding(R$tstr1tstr2((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyt str_compareÜs  c Cs |idƒti|ƒ|iiƒ}x2|iiƒD]!}|i|ƒo ||=q9q9W|i oVxI|i ƒD];\}}|i |ƒ}d||f}|i ||ƒquWh}n|i oÈ|i iƒ}x2|iiƒD]!}|i|ƒo ||=qçqçW| ptd|iƒ‚|o]g}x2|iƒD]$}|id||i|fƒqBWtptddi|ƒ‚qn|idj oZg}xD|iD]9}t|tƒo|i|iƒ}n|i|ƒq°W||_n|iƒ|_dS(Ns %ss6These keys from defaults were not used in the form: %ss%s: %ss*These errors were not used in the form: %ss, (t handle_miscRRRR tcopyR>tkeysthas_keyRtitemstinsert_at_markerR R R=tAssertionErrortappendR3tjoinRt_contentR8R9tdecodet _get_textt_text( R$t unused_errorstkeytvaluet error_messagetunusedt error_textt new_contenttitem((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRîsR        "   cCs|io |ip|iS(N(R2R4R<(R$((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyt skip_outputscCsd|i| required (%s)( tget_attrR3t startswithRttsplitRROtgetposR;R tgetR<R7(R$RmRvtnottedtok((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRj<s   cCsd|_t|_t|_dS(N(RR;R3R<RtR7(R$((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRrKs  cCsÀ|i|dƒ}|i|dƒpd}|djo |i}n|dj ptd|iƒ‚|ii|dƒ}|o$|i||ƒ}|i|ƒnt |_ d|i | required if not contained in (%i:%i)Ri( RwRR;RORzR R{R t write_textRtR7R>(R$RmRvt formatterR((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRiPs   c Cs#|i|dƒpdiƒ}|i|dƒ}|io|i|ƒn|ii|ƒ}|ii|ƒox||i|iƒD]c\}}|i dƒo4|d}|i |||i||dƒ|ƒq…|i |||ƒq…Wn|i o6|i i|i|dƒƒo|i ||i ƒn|djoq|djo$|i o|i|ddƒ}n|i |d|ƒ|id ||ƒt|_|i|ƒnW|d joÊ|io t}n|i|d ƒ}|i|dƒp |}n-|i||i|ddƒƒo t}n|o|i |d d ƒn|i|d ƒ|id ||ƒt|_|i|ƒn€|d jo”|i||i|ddƒƒo|i |d d ƒn/|ip||ijo|i|d ƒn|id ||ƒt|_|i|ƒnß|d jonÎ|djox|djo+|i o |p|i|ddƒ}n|i |d|ƒ|id ||ƒt|_|i|ƒnI|djo-|id ||ƒt|_|i|ƒn|djp|djp |djoV|i |d|p|i|ddƒƒ|id ||ƒt|_|i|ƒn’|iof|djo|i|ddƒ}n|i |d|ƒ|id ||ƒt|_|i|ƒn"dptd||iƒf‚|ip|i|ƒndS(NRCRRvt+iRthiddenRXR`tcheckboxtcheckedtradiotfiletpasswordtimagetsubmittresettbuttonis5I don't know about this kind of : %s (pos: %s)(stextRƒ(RwtlowerRt write_markerR R{R RLRMRxtset_attrRR t add_classRRt write_tagRtR7R_R3tselected_multipletdel_attrRHRRORz( R$RmRnttRvRXt attr_namet attr_valuetselected((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRe_sš                "       '      cCsç|i|dƒ}|io|i|ƒn|io*|ii|ƒo|i||iƒn|ii|dƒ}|p |io=|i d|ƒ|i t |ƒƒ|i dƒt |_ nt |_||_|i|ƒdS(NRvRRas (RwRRŽRR R{RR RR‘R€RRtR4R2R5R_(R$RmRvRX((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRf±s      cCsa|io t|_n|idƒt|_t|_|ip|i|iƒnd|_dS(Ns ( R4R3R€R2RtR7RRŽR5R(R$((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRpÂs      cCs°|i|dtƒ}|o|io|i|ƒn|io*|ii|ƒo|i||iƒn|i|dtƒ|_|i d|ƒt |_ |i |iƒdS(NRvRb( RwR3RRŽRR R{RR6R‘RtR7R_(R$RmRv((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRgÍs  cCsL|idƒt|_|i o|io|i|iƒnd|_dS(Ns (R€RtR7RR6RŽR(R$((s7/usr/lib/python2.6/site-packages/formencode/htmlfill.pyRqÙs   cCsæ|idj ptd|iƒ‚|itjo•|ii|idƒ}|ioo|i|ii|idƒ|i |ddƒƒo'|i |ddƒ|i |iƒqÅ|i |dƒqÉn|i d|ƒt|_dS(Ns0