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

Sam Gendler sgendler@impossible.com
Tue, 18 Jan 2000 10:17:32 -0800


I haven't been reading this thread in detail, but I think I have been doing something that is exactly
what you want to do.

I have a dtml method that calls a ZSQL select query which retrieves the id and title of the entire
list.  I can then list each title as a link, which goes to a new method (we will call it method_2) with
the id of the object passed to it as well.

Basically, just doing <a href="http://some.url.here/method_2?obj_id=&dtml-obj_id;">

method_2 just calls another ZSQL query that does a select * from table where obj_id=<dtml-sqlvar obj_id
integer>, and then populates the web page with data from the query.

Of course, on the first page,  use the dtml-in batch functinos so that the list is not too long.

--sam


Holger Hoffmann wrote:

> 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
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )