hi *,
a strange thing happens calling this controller function by the browser
with its direct url... the mail arrives with no time information so my
client sees it with the date 1/1/1970 1:00... any idea why?
is there a way at least to force the message date?
many thanks
PS
I leave all the code but this function essentially has to write a table
with HTML so don't mind the msg assignment
Manuele
def send_mail_msg():
pannello_out=pannello()
panel_data = pannello_out['panel_data']
available_sites = pannello_out['available_sites']
a = [TH(' ')] + [TH(dates.num2date(d).strftime('%d/%m')) for d in
panel_data['x']] + [TH(' ')]
c = list()
for site in available_sites:
b = list()
for i in panel_data['x']:
l = list()
for j in ['forecast_wind', 'measured_energy']:
try:
l.append(str(panel_data[site.site.id][j][str(i)]))
except:
l.append('np')
b.append(TD(l[0], BR(), l[1]))
x = [TD(site.site.full_name)] + b +
[TD(SiteMaxEnergy(site.power_curve.file_name, power_curves_folder)*24/1000)]
c += [TR(*x, _valign="middle", _align="center")]
msg = str(HTML(BODY(
TABLE(
TR(
TH("Sito"), TH("Energia prevista", BR(), "Energia
immessa", BR(), "(dove disponibile)", BR(), "[%]", _colspan="5"),
TH("Max produzione", BR(), "giornaliera", BR(),
"[MWh]"),
_valign="middle", _align="center"),
TR(*a, _valign="middle", _align="center"),
*c,
_cellpadding="0", _cellspacing="0", _border="1")
), doctype='tag'))[4:]
recipient_list = (
'[email protected]',
)
subject = 'ALERT %s' %(request.now.strftime('%d-%m-%Y %H:%M'))
res = mail.send(to=recipient_list, subject=subject, message=(None,
msg))
return res