Moin Form Create/Submit
Generates arbitrary forms. Submitted data can be processed in two different ways:
- by any action that is able to process submitted data (single action execution only)
by FormSubmit action plugin which can be found in ActionMarket (supports execution of multiple actions)
FormCreate
Note: FormCreate macro should be used together with FormSubmit action plugin.
The following HTML elements are currently supported:
- Text field
- Text area
- Upload field
- Select box
- Check box
- Radio button
- Submit button
For installation all Python files from the download archive (ver. 1.7) must be copied to path wiki/data/plugin/macro/.
This macro does also work on moin version 1.9.6.
FormSubmit
Set of actions to process data from HTML form. Forms should be created by FormCreate macro.
Plugin currently supports the following actions:
submitattachment - attach file into specified wikipage
submitcsv - appends submited data into csv file
submitemail - send submited data on specified email
Note: FormSubmit action plugin should be used together with FormCreate macro.
For installation all Python files from the download archive (ver. 1.7) must be copied to path wiki/data/plugin/action/.
This action plugin does not work on moin version 1.9.6, because the internal structure has changed from version 1.8 to 1.9. In version 1.9 the web framework Werkzeug is used.
Fortunately I could develop a patch to make it run under moin version 1.9.6. The debugging was done with MoinWinpdb.
I have tested the function submitcsv only.
For the changes see the diff files submitbase.diff and submitcsv.diff:
--- Form/form_submit/submitbase.py 2009-09-04 08:16:05.000000000 +0200 +++ moin-1.9.6/wiki/data/plugin/action/submitbase.py 2013-01-01 11:01:52.000000000 +0100 @@ -74,13 +74,13 @@ # file upload is present if request.form.has_key("file"): self.attachFile = request.form.get("file__filename__") - self.attachContent = request.form.get("file")[0] - self.attachLabel = request.form.get("uploadlabel")[0] + self.attachContent = request.form.get("file") # [0] + self.attachLabel = request.form.get("uploadlabel") # [0] self.attachLabel = self.attachLabel.encode('utf-8') # page where all submited data will be stored if request.form.has_key("targetpage"): - targetpage = request.form.get("targetpage")[0] + targetpage = request.form.get("targetpage") # [0] page = Page(self.request, targetpage) if page.isStandardPage(False): self.targetpage = targetpage @@ -204,13 +204,13 @@ def _exclude_metadata(self, form): """ Filter all form metadata and returns only data send by user """ - fields = copy.deepcopy(form) + fields = dict(copy.deepcopy(form)) # hint from ThomasWaldmann for label, value in form.iteritems(): if self.metadata.count(label) > 0: del fields[label] else: - fields[label] = value[0] + fields[label] = value # [0] return fields @@ -222,12 +222,17 @@ """ labels = [] values = [] - + #import rpdb2; rpdb2.start_embedded_debugger("password") if form.has_key('labels'): - _labels = form.get('labels')[0].split(";") + _labels = form.get('labels').split(";") for label in _labels: label = label.encode('utf-8') labels.append(label) +# provide filename, if none is given. RudolfReuter 2012-12-31 + if label == 'Attachment': + if fields.get(label) == None: + if self.targetFile != '': + fields[label] = self.targetFile values.append(fields[label]) else: labels = fields.keys();
--- Form/form_submit/submitcsv.py 2009-09-04 07:32:02.000000000 +0200 +++ moin-1.9.6/wiki/data/plugin/action/submitcsv.py 2013-01-01 10:57:14.000000000 +0100 @@ -31,7 +31,7 @@ self.targetFile = "" if(request.form.has_key("targetfile")): - self.targetFile = request.form.get("targetfile")[0] + self.targetFile = request.form.get("targetfile") # [0] else: self.targetFile = u"list.csv"
In order to apply the patches under Mac OS X and Linux do:
# Example to create the patch files $ diff -u --strip-trailing-cr Form/form_submit/submitbase.py moin-1.9.6/wiki/data/plugin/action/submitbase.py > submitbase.diff $ diff -u --strip-trailing-cr Form/form_submit/submitcsv.py moin-1.9.6/wiki/data/plugin/action/submitcsv.py > submitcsv.diff # Normalize the Python files # cd above moin-1.9.6 # Remove CR at End Of Line $ dos2unix moin-1.9.6/wiki/data/plugin/action/su* $ dos2unix moin-1.9.6/wiki/data/plugin/macro/Fo* # Test the patch, before applying it $ patch --dry-run -p0 < submitbase.diff # if OK apply $ patch -p0 < submitbase.diff # Test the patch, before applying it $ patch --dry-run -p0 < submitcsv.diff # if OK apply $ patch -p0 < submitcsv.diff
List of pages in this category:
-- RudolfReuter 2013-01-01 15:51:10
Go back to CategoryMoinMaintenance or FrontPage ; KontaktEmail (ContactEmail)