[Zope] re: re: [Zope] SQL Queries

Holger Hoffmann hohoff@rz.uni-potsdam.de
Mon, 17 Jan 2000 12:28:25 +0100


Hi,

> each link will call up a page, each page will run a query using the #ID# argument passed by the url
> like
> SELECT from dvdfilms
> Title,ID
> WHERE ID=#url.ID#

i think somthing like /dvdfilm/getFilmData?id=42 is not possible
(Security ?).

This should work:

I assume you have a folder dvdfilms and a table dvdfilm with
colums id, title, description. 

In the dvdfilm folder the index_html document generate the 
series of links:

--- index_html ----

<!--#var standard_html_header-->
<h2><!--#var title_or_id--></h2>
<p>
<dtml-in getAllFilms>
<p><a href="getFilmData/<dtml-var id>/show"><dtml-var title></a></p>
</dtml-in>
</p>
<!--#var standard_html_footer-->

---------------------

You need two sql-methods (getAllFilms and getFilmData):

--- getAllFilms ---

select id, title
from dvdfilm

-------------------

--- getFilmData ---

Argument: id

select *
from dvdfilm
<!--#sqlgroup required where-->
<!--#sqltest id column="id" type="int"-->
<!--#/sqlgroup-->

-------------------- 

and you need a dtml-method show:

--- show ---

<!--#var standard_html_header-->
<H2><dtml-var title></H2>
<p>title:&nbsp;<dtml-var title></p>
<p>description:&nbsp;<dtml-var description></p>
<!--#var standard_html_footer-->

-------------

All documents and methods are in the dvdfilm folder.

In the Advanced Tab for the sql-method getFilmData you
have to check the 'Allow direct traversal' button.

Now, you are able to access something like:

/dvdfilm/getFilmData/42/show

Hope that helps ... Holger