Re: dtml-let variables in sql queries
"Jonathan" <[email protected]>
| Newsgroups | gmane.comp.web.zope.database |
|---|---|
| Message-ID | <000c01c70f1c$57147d50$677ba8c0@DESKTOP> |
----- Original Message ----- From: "Andreas Tille" <[email protected]> To: "Jonathan" <[email protected]> Cc: <[email protected]> Sent: Thursday, November 23, 2006 11:03 AM Subject: Re: dtml-let variables in sql queries > On Thu, 23 Nov 2006, Jonathan wrote: > >>> <params>name nameid >>> >>> </params> >>> SELECT * FROM names >>> WHERE fake = 0 >>> <dtml-if name> >>> AND <dtml-sqltest name op=like type=nb> >>> </dtml-if> >>> <dtml-if nameid> >>> AND <dtml-sqltest nameid op=eq type=int> >>> </dtml-if> >> >> First off, i would highly recommend using python scripts instead of DTML >> for the kind of processing you have described. > > You are right here and I would definitely prefer Python scripts. The > problem is that I'm using the Formulator Product and despite there are > descriptions how to use it with Python scripts I failed while it was > very straigtforeward to use DTML (in fact, this is the only part of > my application in DTML). I just stripped down the application to a > very simple example and avoided Formulator magic which is obviousely > not the source of the problem. > >> That said, you have not described the GetCases method. > > I forgot to mention the name. It is the code snipped above. > >> If GetCases is the name of your SQL method, then you need to pass in the >> parameter 'nameid' > > Well, nameid is not explicitely passed but taken from the parent > out of > > <dtml-let nameid="REQUEST.form['nameid']"> > > and this works. The problem is that name which is builded > out of > > <dtml-let namepart="REQUEST.form['namepart']"> > Namepart = <dtml-var namepart><br /> > <dtml-let name="namepart + '%'"> > > is ignored by the SQL method and I fail to see the difference. > The <dtml-if name> seems to be false in any case. It may be due to the fact that the 'let' statement creates a variable in another part of the 'namespace' (ie. not in the REQUEST namespace). You could test this theory by replacing the dtml-let with a dtml-call REQUEST.set eg. <dtml-let namepart="REQUEST.form['namepart']"> Namepart = <dtml-var namepart><br /> <dtml-call "REQUEST.set('name', namepart + '%')"> hth Jonathan