[Zope] Creating and displaying lists
Jonathan
dev101 at magma.ca
Thu Jul 13 16:30:38 EDT 2006
<snip>
----- Original Message -----
From: larrymcdonnell at att.net
To: zope at zope.org
Sent: Thursday, July 13, 2006 4:03 PM
Subject: [Zope] Creating and displaying lists
I need to collect a list of student id numbers from one table so I can take
this list, find them in another table, and display their names so their
teachers can give them a score.
I still like to use DTML but I do not know if I have the sequence-number in
the proper format. This is what I have been playing with:
<dtml-call "REQUEST.set('RECORD_ID', REQUEST.SESSION['RECORD_ID'])">
<dtml-in lookup_students_in_course>
<dtml-call "REQUEST.set('student_id_temp', student_id)">
</dtml-in>
<dtml-in expr="_.range(sequence-number)">
<dtml-call "REQUEST.set('student_id_temp', student_id_temp)">
<SELECT NAME="student_id_selected">
<option value=""></option>
<dtml-in lookup_student_name sort=student_last_name>
<OPTION VALUE="<dtml-var student_id>">
<dtml-var student_last_name>, <dtml-var student_first_name>
</OPTION>
</dtml-in>
</SELECT>
</dtml-in>
</snip>
I think there is some confusion here. You should break this into 2 sections
(and it would be much easier in a python script), but if you want to use
dtml...
The first section should build the list you are trying to display in the
SELECT statement. It looks like you are trying to create a list of 'tuples'
where each tuple consists of (id, lastname, firstname). I don't know where
your data is coming from, but you could do something like:
<dtml-call "REQUEST.set('studentList', [])"> # creates an empty list
<in some loop>
<dtml-call "studentList.append( (id, lastname, firstname) )"> # add one
tuple (record) to the list
<end of loop>
After you have built your list test it by displaying it: <dtml-var
studentList> to see if you have the right data in your list.
You can then proceed to the next section where you are building your SELECT
statements (warning: not tested and very ugly dtml)
<select size="1" name="student_id_selected">
<dtml-in studentList>
<option value="<dtml-var "_['sequence-item'][0]">" >
<dtml-var "_['sequence-item'][1]">, <dtml-var
"_['sequence-item'][2]">
</option>
</dtml-in>
</select>
hth & Good Luck
Jonathan
More information about the Zope
mailing list