[Zope] Two questions...
Chris McDonough
chrism@digicool.com
Wed, 09 Feb 2000 18:03:05 -0500
Wait, wait, I just realized that code's all messed up. It doesn't
work. Neither will this probably, but here goes.
<dtml-call expr="REQUEST.set(my_csv_list, '')">
<dtml-in sqlQuery>
<dtml-if sequence-start>
<dtml-call expr="my_csv_list = my_csv_list + email_address">
<dtml-else>
<dtml-call expr="my_csv_list = my_csv_list + ', ' + email_address">
</dtml-if>
</dtml-in>
<dtml-sendmail>
To:<dtml-var my_csv_list>
From: me@myplace.com
Hi!
</dtml-sendmail>
Chris McDonough wrote:
>
> Guy Davis wrote:
> >
> > 1) Given a ZSQL method that takes one arguement (a primary key) how can
> > I pass that information on from where I call the ZSQL method with
> > <dtml-in>
> > i.e. In a DTML method, what comes just before this line if I know that
> > login is davis.
> > <dtml-in getUserSQL size=1 start=query_start>
>
> <dtml-in expr="getUser(login='davis')">
> ..do stuff..
> </dtml-in>
>
> >
> > I have tried:
> > <dtml-let login="_.string.lower('davis')">
> >
> > <dtml-call "REQUEST.set('login', 'davis')">
> > This works the first time I call getUserSQL, but breaks the second time
> > with a different login as it appears I can only set the login variable
> > once.
> >
> > 2) Since you can't have <dtml-sendmail mailto="<dtml... get emails from
> > database. (nested <dtml> statements), how does one iteratively declare a
> > list variable and then add to it. Then my mailto="_.string.join(listvar,
> > ', ')" will work.
>
> You need to build a comma-separated list of email addresses and pass it
> to the sendmail snippet in your code:
>
> <dtml-sendmail>
> To:<dtml-var my_comma_sep_list>
>
> MY BODY
> </dtml-sendmail>
>
> You can build the string by using a REQUEST variable.
>
> <dtml-var expr="REQUEST.set('my_comma_sep_list', '')>
>
> <dtml-in mySQLQueryThatGetsABunchOfEmailAddresses>
> <dtml-call expr="my_comma_sep_list.append(email_address)">
> </dtml-in>
>
> It gets more complicated because you need to make sure the email address
> is "OK" before you append it, otherwise SMTP will choke on it when Zope
> tries to dump it off (messages will be sent to no one). You can do this
> by using the monster regular expression on the last page of Jeffrey
> Friedl's "Mastering Regular Expressions".
>
> >
> > It seems the majority of my problems are due to thinking in C,C++ or
> > Java where one can simply declare a variable and then work with it. I
> > haven't figured out how to do that in DTML. Any help you can offer is
> > appreciated.
>
> You might be better off doing all this in an External Method.
>
> --
> Chris McDonough - Digital Creations, Inc.
> Publishers of Zope - http://www.zope.org
>
> _______________________________________________
> 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 )
--
Chris McDonough - Digital Creations, Inc.
Publishers of Zope - http://www.zope.org