[ZPT] validation in a table

Justyna Tomczyk celtek at wp.pl
Sat Aug 13 19:07:26 EDT 2005


Hi,
I have a table with results from database(MySQL). I can edit every field in this table (change data and save it in database). Problem is that I don't know how to validate every field in this table before I want to save this changed data in database.
I've tried figured out how to validate this data but without results. Now I am really in a whirl. What and where I should insert ?
Any clue? Any help? 
 
Here is a bit of code from ZPT :
 
<!--<table class="listing" tal:define=students python:container.get_data(Term=request.form['Term']);   
                                                    sort_on python:(('matricula','cmp','asc'),('name','nocase','desc'));
                                                    sorted_objects python:sequence.sort(students, sort_on)">
<thead>
 <tr>
        <th>Id</th>
        <th>Term</th>
        <th>Matricula Number</th>
        <th>Name</th>
        <th>Action</th>  
</tr>
</thead>
<tbody>  
<tr tal:repeat="s sorted_objects" tal:attributes="class python:test( repeat['s'].even() ,'even','odd')"> 
 
<form action="edit" method="post"> 
 
<td tal:content="string:${repeat/s/number}."></td>
<td>
<input type="text" name="Id" tal:attributes="value s/Id" />
</td>
<td>
<input type="text" name="term" tal:attributes="value s/term" />
</td>
<td>
<input type="text" name="matricula" value="" tal:attributes="value s/matricula" />
</td>
<td>
<input type="text"   name="name"  value="" tal:attributes="value s/name"/>
</td>
<td><input class="context" type="submit" name="button.edit" value="Change"/>
</td>
</form>
</tr>
</tbody>-->

 
from Script(Python):
 
#from Products.Formulator.Form import FormValidationError
#request = context.REQUEST
#RESPONSE = request.RESPONSE
 
#matricula=request.form.get('matricula')
#name=request.form.get('name')
#term=request.form.get('term'))
#Id=request.form.get('Id')

#container.sql_corect(matricula=matricula,name=name,term=term,Id=Id)
#return RESPONSE.redirect('show_table?message=data was changed ! ')

 
from ZSQLMethod:
 
update students set
matricula = <dtml-var matricula>, 
name = '<dtml-var name>', 
term = <dtml-var term>
where Id = <dtml-var Id>



----------------------------------------------------
I Ty możesz nabrać fantastycznych mocy! 
Mister Fantastic, Niewidzialna kobieta, Ludzka pochodnia i Stwór 
- Fantastyczna czwórka, w kinach od 19 sierpnia.
http://klik.wp.pl/?adr=www.film.wp.pl%2Ffilm.html%3Fid%3D23237&sid=463




More information about the ZPT mailing list