1.1 --- a/MoinForms.py Mon Dec 03 00:51:41 2012 +0100
1.2 +++ b/MoinForms.py Mon Dec 03 01:08:19 2012 +0100
1.3 @@ -266,41 +266,6 @@
1.4
1.5 # Common formatting functions.
1.6
1.7 -def formatForm(text, request, fmt, attrs=None, write=None):
1.8 -
1.9 - """
1.10 - Format the given 'text' using the specified 'request' and formatter 'fmt'.
1.11 - The optional 'attrs' can be used to control the presentation of the form.
1.12 -
1.13 - If the 'write' parameter is specified, use it to write output; otherwise,
1.14 - write output using the request.
1.15 - """
1.16 -
1.17 - write = write or request.write
1.18 - page = request.page
1.19 -
1.20 - fields = getFields(get_form(request))
1.21 -
1.22 - queryparams = []
1.23 -
1.24 - for argname in ["fragment", "action"]:
1.25 - if attrs and attrs.has_key(argname):
1.26 - queryparams.append("%s=%s" % (argname, attrs[argname]))
1.27 -
1.28 - querystr = "&".join(queryparams)
1.29 -
1.30 - write(fmt.rawHTML('<form method="post" action="%s">' %
1.31 - escattr(page.url(request, querystr))
1.32 - ))
1.33 -
1.34 - # Obtain page text for the form, incorporating subregions and applicable
1.35 - # sections.
1.36 -
1.37 - output = getFormOutput(text, fields)
1.38 - write(formatText(output, request, fmt, inhibit_p=False))
1.39 -
1.40 - write(fmt.rawHTML('</form>'))
1.41 -
1.42 def getFormOutput(text, fields, path=None):
1.43
1.44 """
1.45 @@ -608,6 +573,43 @@
1.46
1.47 return elements
1.48
1.49 +# Parser-related formatting functions.
1.50 +
1.51 +def formatForm(text, request, fmt, attrs=None, write=None):
1.52 +
1.53 + """
1.54 + Format the given 'text' using the specified 'request' and formatter 'fmt'.
1.55 + The optional 'attrs' can be used to control the presentation of the form.
1.56 +
1.57 + If the 'write' parameter is specified, use it to write output; otherwise,
1.58 + write output using the request.
1.59 + """
1.60 +
1.61 + write = write or request.write
1.62 + page = request.page
1.63 +
1.64 + fields = getFields(get_form(request))
1.65 +
1.66 + queryparams = []
1.67 +
1.68 + for argname in ["fragment", "action"]:
1.69 + if attrs and attrs.has_key(argname):
1.70 + queryparams.append("%s=%s" % (argname, attrs[argname]))
1.71 +
1.72 + querystr = "&".join(queryparams)
1.73 +
1.74 + write(fmt.rawHTML('<form method="post" action="%s">' %
1.75 + escattr(page.url(request, querystr))
1.76 + ))
1.77 +
1.78 + # Obtain page text for the form, incorporating subregions and applicable
1.79 + # sections.
1.80 +
1.81 + output = getFormOutput(text, fields)
1.82 + write(formatText(output, request, fmt, inhibit_p=False))
1.83 +
1.84 + write(fmt.rawHTML('</form>'))
1.85 +
1.86 def formatFormForOutputType(text, request, mimetype, attrs=None, write=None):
1.87
1.88 """