Overview

The Form macro displays forms based on database records. The records can be edited or deleted. New records can be inserted. The macro also supports sub forms, filters and table views. Currently connections to SQLite, ODBC, MySQL and Oracle DB connections are supported. Of course any database source accessible by ODBC is supported. Even connections to SQLite attachments are supported.

Usage

A form is defined by it's design which is build by moin markup and it's attributes which are specified on a dictionary page.

Form design
<<Form(Start)>>
|| Name       || <<Form(Text, Recipes/FormsDict..Name, 30)>>     ||
|| Category   || <<Form(Text, .Category, 30)>>                   ||
|| Servings   || <<Form(Text, .Servings, 4)>>                    ||
|| Energy     || <<Form(Text, .Energy, 4)>> Cal.                 ||
|| Time       || <<Form(Text, .Time, 4)>> minutes                ||
|| Difficulty || <<Form(Text, .Difficulty, 4)>>                  ||
|| Procedure  || <<Form(Textarea, .Procedure, 50, 8)>>           ||
||<-2><<Form(Hidden, .Id)>><<Form(Buttons)>><<Form(Navigation)>> ||
<<Form(End)>>
Form and connection attributes
= Database Connection =
 .type:: `sqlite`
 .file:: `attachment:Recipes.db`

= Form =
 .select:: `select * from Recipes order by Name`
 .update:: `update Recipes set Name=?, Category=?, Servings=?, Energy=?, Time=?, Difficulty=?, Procedure=? where Id=?`
 .update_parameters:: `.Name, .Category, .Servings, .Energy, .Time, .Difficulty, .Procedure, .Id`

 .insert:: `insert into Recipes(Name, Category, Servings, Energy, Time, Difficulty, Procedure) values(?, ?, ?, ?, ?, ?, ?)`
 .insert_parameters:: `.Name, .Category, .Servings, .Energy, .Time, .Difficulty, .Procedure`

 .delete:: `delete from Recipes where Id=?`
 .delete_parameters:: `.Id`

This example displays the following editable form:

For a quick introduction on using the Form macro, see /Help/Tutorial. For a detailed explanation see /Help/Reference.

Setup

Requirements

The Form macro is compatible with Moin 1.6/1.7/1.8/1.9 (RudolfReuter).

For SQLite connections

With Python 2.5 no additional components are needed. With Python 2.4 however you have to make some adjustments. These are described in /Bugs/IndexUndefined (currently only in german language).

For ODBC connections

Install pyodbc library (http://code.google.com/p/pyodbc/)

For MySQL connections

Install MySql for Python (http://sourceforge.net/projects/mysql-python)

For Oracle connections

The prerequisites for Oracle database connections should be the same as for the MacroMarket/SQL macro. I'm not able to verify this.

/!\ There is however a change to this: The ORACLE_HOME environment path is not set by the macro code any more. It should be set in your operating system.

Download

Review the /ReleaseNotes. Download the current version (Form-0.8alpha.py).
For moin 1.7/1.8 you need (Form-0.9alpha.py) and Python Version >=2.5 (2008-12-25 RudolfReuter).
For moin1.8/1.9 (Linux) you need (Form-0.11alpha.py) (2010-01-29 RudolfReuter)
For moin 1.9.7 you need (Form-0.12alpha.py) from TestTest. (2014-06-12 RudolfReuter)

Install

Rename the file toForm.py and copy it to your /data/plugin/macro directory.

Configure

The following configuration options can be set in the wikiconfig.py:

Option

Description

Default

form_macro_dicts

[Not implemented yet!] A list of pages allowed to contain form or connection definitions. If set only forms and connections defined on these pages are allowed.

[ ]

Development

Developer wanted

Currently I'm not able to continue the development of this macro in the same way I did before. If you are interested in MoinMoin having a macro handling database forms and know Python please feel free to continue developing this macro. You are welcome to publish updated versions of the macro here. Even small improvements are appreciated.

Feedback

{i} Please use the sub pages /Bugs to report bugs, /Questions to post questions and /FeatureRequests to post feature requests. Other feedback can be posted here.

MoinMoin: MacroMarket/Form (last edited 2014-06-12 10:41:58 by RudolfReuter)