Ticket #926 (new enhancement) — at Version 2

Opened 3 years ago

Last modified 3 years ago

Pick a simpler form framework

Reported by: sebbacon Owned by: sebbacon
Priority: critical Milestone: ckan-v1.4-sprint-1
Component: ckan Keywords: forms
Cc: Repository:
Theme:

Description (last modified by rgrp) (diff)

The current formalchemy setup conflates view, controller and model code in a way that makes it hard to debug and customise.

Review existing (and potentially non-existing) frameworks with a view to porting forms over to something more explicit and lightweight.

Implement the current Package forms as an example of how this would work.

Document and circulate.

Sub-ticket of #961 (form, validation, model sync meta-ticket)

Change History

comment:1 Changed 3 years ago by rgrp

  • Priority changed from awaiting triage to critical
  • Milestone set to ckan-v1.4-sprint-1

Comments from RP - http://lists.okfn.org/pipermail/ckan-dev/2011-January/000181.html

Libraries I have used: FormEncode?, FormAlchemy? (what we are currently using, before that formencode).

Neither seemed perfect but I think the form issue is a 'hard' problem (perhaps with no perfect answer) [1]. FormAlchemy?, in retrospect, was probably a mistake as it merges too much model/validation/form generation into one thing.

At least 3 functions involved:

  1. Generating (or just filling) a form template with 'form data' (and errors)
  2. Converting model data to form data (also happens for APIs in fact) -- let's call this 'dict-ization'
  3. Converting form data to model data (and validating) (inverse of

previous step)

I think one can and should separate 1 from 2+3 (and one of problems with formalchemy is it doesn't -- the attraction being you don't repeat yourself as forms get generated from model but I think this is actually a false economy in medium-term).

I'm not specifically recommending the following as I haven't used them but I've looked through docs, they are active and reasonably mature:

  1. Flatland: http://discorporate.us/projects/flatland/docs/tip/
    • Only does 2+3 which is a good thing IMO
  1. WTForms: http://wtforms.simplecodes.com/

comment:2 Changed 3 years ago by rgrp

  • Description modified (diff)
Note: See TracTickets for help on using tickets.