[Zope] - Re: Zope - YASQ (yet another stupid question)

Chad Fowler cfowler@fedex.com
Wed, 23 Dec 1998 16:17:50 -0600


Amos,

Thanks for your encouraging response.  I think I should provide a little more
detail.
What I am specifically trying to do is look up a value from a DB table for
every record
returned from another DB table.
For example, if I had a database of Overtime hours worked for company
employees, for
each record in the "OThours" table, I would look up "fullname" and
"phonenumber" based
on "employeenumber" out of the "Employees" table.

So, what I have done (and, I'm sure it's somehow flawed) is create a SQL Method

that returns multiple rows from the "OThours" table, and using the <!--#in tab,
looped
through each one, displaying the data.  I'm trying to display the Employee Name
and Phonenumber
from the "Employees" table instead of the employeenumber that is stored with
each record in the
"OThours" table.  The way I have approached this part is to create another SQL
Method called
getName (for example) which takes an argument called "eid", and inside my
<!--#in loop, have something like the following:

<!--#in getAllOThours-->
Hours work: <!--#var hoursworked-->
Emp. Name: <!--#var expr="getName(eid=<!--#var employeenumber-->)"-->
<!-- yes, i realize the above definitely doesn't work, but you see what i'm
getting at :) -->
Mood: <!--#var mood-->
<!--#/in-->

If I replace the offending line with:
Emp. Name: <!--#var
expr="getName(eid='someemployeeidthatactuallyexistshardcodedin')"-->
....I can make it work.

I'm sure I'm doing this backward or something.  I've read all of the
documentation I can find at this point.
I'm sure this is a simple problem of me just going about it the wrong way.

Sorry for the long and confusing email.

Chad Fowler

Amos Latteier wrote:

> At 02:55 PM 12/23/98 -0600, Chad Fowler wrote:
>
> >Say you have an external method, or a SQL Method that accepts a
> >parameter.
> >You want that parameter to be dynamic (possibly based on a field from a
> >DB).
> >How can you pass a dynamic parameter to a method from within DTML?
> >
> >i.e.:
> ><!--#in expr="getSpam(cost=<!--#var spamcost-->)"-->
>
> What you've got is basically right, it's just a question of syntax. In
> general you can refer to variables defined in the REQUEST by name:
>
> <!--#in expr="getSpam(spamcost)"-->
>
> Sometimes there are problems with this, if for example you want access to
> special sequence-item variable. In these cases you can lookup variables in
> the namespace mapping object (whose unpronounceable name is written '_')
> like so:
>
> <!--#var expr="getSpam(_['spamcost'])"-->
>
> For an example of how to use this namespace feature to include random bits
> of content see:
>
> http://www.zope.org/Documentation/HowTo/RandomContent
>
> You should also check out the DTML Users Guide which spells out pretty well
> how to use DTML:
>
> http://www.digicool.com/site/Principia/DTML.html
>
> Hope this helps. And BTW, DTML *is* complex; your question is not stupid.
>
> -Amos