# HG changeset patch # User Paul Boddie # Date 1354493299 -3600 # Node ID 174626432da0d21d3075250854b20426a32321bd # Parent 11d6e15c8b0c5ef3bbd8571d0da4bc77db3c4413 Grouped the higher-level formatting functions. diff -r 11d6e15c8b0c -r 174626432da0 MoinForms.py --- a/MoinForms.py Mon Dec 03 00:51:41 2012 +0100 +++ b/MoinForms.py Mon Dec 03 01:08:19 2012 +0100 @@ -266,41 +266,6 @@ # Common formatting functions. -def formatForm(text, request, fmt, attrs=None, write=None): - - """ - Format the given 'text' using the specified 'request' and formatter 'fmt'. - The optional 'attrs' can be used to control the presentation of the form. - - If the 'write' parameter is specified, use it to write output; otherwise, - write output using the request. - """ - - write = write or request.write - page = request.page - - fields = getFields(get_form(request)) - - queryparams = [] - - for argname in ["fragment", "action"]: - if attrs and attrs.has_key(argname): - queryparams.append("%s=%s" % (argname, attrs[argname])) - - querystr = "&".join(queryparams) - - write(fmt.rawHTML('
' % - escattr(page.url(request, querystr)) - )) - - # Obtain page text for the form, incorporating subregions and applicable - # sections. - - output = getFormOutput(text, fields) - write(formatText(output, request, fmt, inhibit_p=False)) - - write(fmt.rawHTML('
')) - def getFormOutput(text, fields, path=None): """ @@ -608,6 +573,43 @@ return elements +# Parser-related formatting functions. + +def formatForm(text, request, fmt, attrs=None, write=None): + + """ + Format the given 'text' using the specified 'request' and formatter 'fmt'. + The optional 'attrs' can be used to control the presentation of the form. + + If the 'write' parameter is specified, use it to write output; otherwise, + write output using the request. + """ + + write = write or request.write + page = request.page + + fields = getFields(get_form(request)) + + queryparams = [] + + for argname in ["fragment", "action"]: + if attrs and attrs.has_key(argname): + queryparams.append("%s=%s" % (argname, attrs[argname])) + + querystr = "&".join(queryparams) + + write(fmt.rawHTML('
' % + escattr(page.url(request, querystr)) + )) + + # Obtain page text for the form, incorporating subregions and applicable + # sections. + + output = getFormOutput(text, fields) + write(formatText(output, request, fmt, inhibit_p=False)) + + write(fmt.rawHTML('
')) + def formatFormForOutputType(text, request, mimetype, attrs=None, write=None): """