On 18/07/2011 18:00, Anthony wrote:
Looks like mail.send() calls time.gmtime(). What happens if you do the
following:
def time_test():
import time
return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
and go to the default/time_test URL -- do you get the correct time?
Anthony
well I'm sure I'll get the correct time
in fact I made in the code print the time stamp in the mail subject (I
reported here under the code)
> subject = 'ALERT %s' %(request.now.strftime('%d-%m-%Y %H:%M'))
and I obtained the correct time when I received the mail:
> ALERT 18-07-2011 15:55
anyway yesterday I included the controller in a scheduled crontab
command and I have received mail with a correct timestamp... strange
behaviour
many thanks
M.
On Monday, July 18, 2011 10:06:35 AM UTC-4, Manuele wrote:
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 <http://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