I am not sure what is wrong here, and the example is complex so I
cannot understand the details. Nevertheless, I suggest replace

response.render('clublocatormail/send_mail.html',context)

 with

from gluon.template import render

render(filename='clublocatormail/send_mail.html',context=context)

see if there is any difference.

Also try isolate the problem and simplfy send_mail.html so the point
that it contains only the line that causes the trouble.

Massimo


On Apr 17, 3:26 am, annet <[email protected]> wrote:
> I converted the send_mail function to a none mail function. The
> send_mail function:
>
> def send_mail():
>
> mailinglist=db((db.bedrijfcontactpersoon.bedrijf==db.bedrijf.id)&(db.bedrijfcontactpersoon.bedrijf==db.bedrijfinschrijving.bedrijf)&
> \
>
> (db.bedrijfcontactpersoon.contactpersoon==db.contactpersoon.id)&(db.bedrijfinschrijving.inschrijving==2)&
> \
>     (db.contactpersoon.subscription==True))\
>     
> .select(db.bedrijf.bedrijfsnaam,db.bedrijfcontactpersoon.bedrijf,db.contactpersoon.id,db.contactpersoon.email,
> \
>     orderby=db.bedrijfcontactpersoon.bedrijf)
>     for item in mailinglist:
>         context=dict(item=item)
>         message=response.render('clublocatormail/
> send_mail.html',context)
>         recipient=item.contactpersoon.email
>         boolean=mail.send(to=[recipient],subject='Bedrijfsgegevens ' +
> item.bedrijf.bedrijfsnaam + ' in Fitwise',message=[None,message])
>         if boolean:
>
> db.mailing_stats.insert(bedrijf=item.bedrijfcontactpersoon.bedrijf,contactpersoon=item.contactpersoon.id,
> \
>             controller='clublocatormail',functie='send_mail')
>         else:
>
> db.admin_stats.insert(bedrijf=item.bedrijfcontactpersoon.bedrijf,contactpersoon=item.contactpersoon.id,
> \
>             controller='clublocatormail',functie='send_mail')
>     return True
>
> ... and its view:
>
> <html>
>   <head>
>     <meta http-equiv="Content-Type" content="text/html;
> charset=utf-8" />
>     <title>Template - Single Column</title>
>   </head>
>   <body>
>     <style type="text/css" media="screen">
>     </style>
>     <table class="bg1" width="100%" border="0" cellspacing="0"
> cellpadding="0">
>       <tbody>
>         <tr>
>           <td align="center">
>             <table class="bg2" width="600" border="0" cellspacing="0"
> cellpadding="0">
>               <tbody>
>                 <tr>
>                   <td class="browserversion" align="left">
>                     <p>Having trouble viewing this email? {{=A('View
> it in your browser',
> _href=URL(r=request,c='clublocatormail',f='browser_version',args=[item.bedrijfcontactpersoon.bedrijf,item.contactpersoon.id]),
> _target="_blank")}}</p>
>                   </td>
>                 </tr>
>                 <tr>
>                   <td class="header" align="left">
>                     <img src="{{=URL(r=request,c='static',f='template/
> header.jpg')}}" alt="Header" width="600" height="192" />
>                   </td>
>                 </tr>
>                 <tr>
>                   <td valign="top" class="body">
>                     <table width="100%" border="0" cellspacing="0"
> cellpadding="0">
>                       <tbody>
>                         <tr>
>                           <td class="content" valign="top"
> align="left">
>
>                             <h2>Fitwise</h2>
>
>                             <p>Fitwise is een informatie en
> communicatie tool op internet waarmee u uw klanten en potenti&#235;le
>                             klanten moeiteloos bereikt en waarmee zij
> u moeiteloos kunnen vinden via onze
>                            {{=A('club locator',
> _href=URL(r=request,c='clublocatormail',f='clublocator',args=[item.bedrijfcontactpersoon.bedrijf,item.contactpersoon.id]),
> _target="_blank")}}.
>                            Als ondernemer wilt u natuurlijk dat uw
> bedrijfsgegevens in ons systeem up-to-date zijn. Controleer daarom
>                            {{=A('uw bedrijfsgegevens in Fitwise',
> _href=URL(r=request,c='clublocatormail',f='check_details',args=[item.bedrijfcontactpersoon.bedrijf,item.contactpersoon.id]),
> _target="_blank")}}</p>
>
>                             <p>Zijn uw bedrijfsgegevens in ons systeem
> niet up-to-date of wilt u uzelf als contactpersoon aanmelden. Vul dan
> het
>                            {{=A('wijzigingsformulier',
> _href=URL(r=request,c='clublocatormail',f='update_form',args=[item.bedrijfcontactpersoon.bedrijf,item.contactpersoon.id,]),
> _target="_blank")}} in.
>                            Zijn uw bedrijfsgegevens in ons systeem up-
> to-date? Laat het ons weten via het
>                            {{=A('bevestigingsformulier',
> _href=URL(r=request,c='clublocatormail',f='update_form',args=[item.bedrijfcontactpersoon.bedrijf,item.contactpersoon.id,]),
> _target="_blank")}}.</p>
>
>                             <p class="signature"><br />Met
> vriendelijke groet<br />
>                             </p>
>
>                           </td>
>                         </tr>
>                       </tbody>
>                     </table>
>                   </td>
>                 </tr>
>                 <tr>
>                   <td class="footer" valign="middle" align="left"
> height="61">
>                     <p>Not interested anymore? {{=A('Unsubscribe',
> _href=URL(r=request,c='clublocatormail',f='unsubscribe',args=[item.bedrijfcontactpersoon.bedrijf,item.contactpersoon.id,]))}}
> </p>
>                   </td>
>                 </tr>
>               </tbody>
>             </table>
>           </td>
>         </tr>
>       </tbody>
>     </table>
>   </body>
> </html>
>
> The not_send_mail function:
>
> def not_send_mail():
>
> item=db((db.bedrijfcontactpersoon.bedrijf==db.bedrijf.id)&(db.bedrijfcontactpersoon.bedrijf==db.bedrijfinschrijving.bedrijf)&
> \
>
> (db.bedrijfcontactpersoon.contactpersoon==db.contactpersoon.id)&(db.bedrijfinschrijving.inschrijving==2)&
> \
>     (db.contactpersoon.subscription==True))\
>     
> .select(db.bedrijf.bedrijfsnaam,db.bedrijfcontactpersoon.bedrijf,db.contactpersoon.id,db.contactpersoon.email,
> \
>     orderby=db.bedrijfcontactpersoon.bedrijf)
>     return dict(item=item)
>
> ... and in its view, which is identical to the one above, I replaced
> the item attributes with item[0]. When I expose the latter the _href
> and scr attributes are rendered correctly:
>
> <td class="browserversion" align="left">
> <p>"Having trouble viewing this email?"
> <a href="/mock_crm/clublocatormail/browser_version/2/2"
> _target="_blank">View it in your brwoser</a>
> </p>
> </td>
>
> <td class="header" align="left">
> <img src="/mock_crm/static/template/header.jpg" alt="Header"
> width="600" height="192" >
> </td>
>
> Is it the response.render() function that is causing the problem, or
> something else?
>
> Kind regards,
>
> Annet.
>
> --
> Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en

Reply via email to