[Zope] dtml-let and MySQL

Richard Moon richard@dcs.co.uk
Mon, 20 Mar 2000 16:33:44 +0000


As I understand it any variables you set in <dtml-let> </dtml_let> blocks 
are local to that block of code. There's no way to 'pass' them to an SQL 
Method. SQL Methods only use values which have been set within the REQUEST 
variable. The REQUEST variable is where Form variables are held - but Form 
variables only exist until the next Form is called. You can however 
explicitly force values into REQUEST using the syntax

<dtml-call expr="REQUEST.set('yourvariable','yourvalue')">

and these would then be available to an SQL Method.

A tip which I found very useful when working with the REQUEST variable and 
forms is to put the following line into your code
<dtml-var REQUEST>.

This displays all the current values within the REQUEST variable.

There's also a useful How-To on Namespaces which gives more background on 
this area (search for Namespace in www.zope.org).

However IMHO its an area of Zope that needs a lot more documentation and 
tutorials because I don't think it's very intuitive.

I also think it would be nice to have a version of SQL method which allowed 
you to pass the values you want into it - it's beyond me at the moment though.

Good luck


Richard

At 02:08 20/03/00 -0800, you wrote:
>Hi,
>
>   I've tried to write one generic SQL method and
>passing argument to my SQL method using dtml-let but I
>got KeyError. I've tried it with dtml-with also but
>same thing.
>
>In my page I use:
>
><dtml-let curpage=total>
>   <dtml-call hitinsert>
></dtml-let>
>
>and MySQL method is:
>
>update zp_stat
>set <dtml-var curpage>  = <dtml-var curpage> + 1
>
>What I want to do, is passing mySQL argument and
>using one method. Ex:
><dtml-let curpage=astro>
>         <dtml-call hitinsert>
></dtml-let>
>
>total and astro are INT in my SQL table.
>
>I dont know if dtml-let is a right way?
>
>Any suggestion to do this?
>
>Thank's
>
>
>
>
>__________________________________________________
>Do You Yahoo!?
>Talk to your friends online with Yahoo! Messenger.
>http://im.yahoo.com
>
>_______________________________________________
>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 )
>


Richard Moon
richard@dcs.co.uk