Re: [Zope-DB] Checkboxes selecting records...

2006-02-12 Thread Maciej Wisniowski

Hi!

I have a list of records that come from a database select query 
(dtml-in horses).


I suggest you to use Python Script to get data from DB and then
ZPT to display results (if you're using ZMI level scripting).
DTML is recomended to use only in ZSQLMethods.


You may want to use ':list' on your page with checkboxes, like:


 (...)
 (...)

then, on confirm page you will get 'horse_ids' from request as
a python list (notice that without :list you'll get scalar value
if only one checkbox is chosen or list when two or
more checkboxes are selected), with :list you always
have list, or None when no checkbox is chosen.


How can I get records with id 1,2,3 out of the database



table? Then can those records be saved onto a html page for use later?



On the confirm page you should store horse_ids list in session
(to be able to use this later), like:

request.SESSION.set('my_horses', horse_ids)

then you should call another ZSQLMethod with horse_ids list as parameters
to get only previously selected horses.
It should be converted to sql like:

select * from table_horses where horse_id in (1, 3, 4, 6)

You can find how to write such ZSQLMethod in Zope Book (chapter about
relational database connectivity).

Hope I understood you correctly :)

--
Maciej Wisniowski

___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


[Zope-DB] Checkboxes selecting records...

2006-02-11 Thread Rich Harley
Hi all

Not sure if I'm on the right lines with what I'm trying to do below.

I have a list of records that come from a database select query (dtml-in 
horses). Next to each record is a check box. I want to be able to select the 
checkbox of x number of records, submit the form and see just those records, 
minus the ones I didn't check. This will be the confirm page. When I have 
confirmed my selections, the said records should then be stored on a page so 
I can view them later, like a permanent select query I suppose that I can 
view at any time. For each time I select and confirm some records, a new 
page, with those records on, should be created. Am I correct in guessing I 
have to use the id as the identifier? I've got as far as passing the results 
of the checkbox form onto onto the confirm page - but only displaying 1,2,3 
etc or whichever ones I check. How can I get records with id 1,2,3 out of the 
database table? Then can those records be saved onto a html page for use 
later? I'm using mysql, if that makes any difference.

Sorry for all the (probably simple) questions!

Thanks in advance.

Rich

___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db