[mod_python] Validating input - Form Handler component

Julien Cigar jcigar at ulb.ac.be
Thu Oct 5 07:38:12 EDT 2006


Hello,

What I ususally do is a Model object with properties, something like 
this: http://rafb.net/paste/results/LwMH9m76.html
Then in my Controller I have a method to parse the form, something like :

def parse_form(self, themodelobject) :
    errors = []
    for col in themodelobject.columns:
       try:
          setattr(themodelobject, col, self.params.get[col])
       except Exception, e:
          errors.append(str(e))
    return errors

def add(self):
    errors = parse_form(myModel())
    if not errors:
        ...
    else:
        ...
      

(it's a basic and limited example, but it show you the principle)

Julien

durumdara wrote:
> Hi !
>
> Do you knows about a Form handler component (module, class, unit, 
> package, etc.) that can uniformize the form handling on the web ?
>
> The html form handling forces me to I repeat some of the codes in many 
> modules.
>
> Example:
> 1. Init
> 2. Get inputs
> 3. Validating inputs: check field names, data types, I need to open 
> queries to see that actual data is valid (and existing), require all 
> the fields I need to make the next step, convert data from text to any 
> type, protect fields from SQL injection, etc.
> 3. Make operation (insert, update, delete, or select)
> 4. Show the results, build the result table and/or the form again.
>
> These steps are repeating modules by modules...
>
> Do you heard about something like this, or I need to write this 
> component ?
>
> Thanks for your help:
> dd
>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python


-- 
Julien Cigar
Belgian Biodiversity Platform
http://www.biodiversity.be
Université Libre de Bruxelles
Campus de la Plaine CP 257
Bâtiment NO, Bureau 4 N4 115C (Niveau 4)
Boulevard du Triomphe, entrée ULB 2
B-1050 Bruxelles
office: jcigar at ulb.ac.be
home: mage at mordor.ath.cx



More information about the Mod_python mailing list