Message from discussion
Best practise of writing send mail console script which sends out i18n messages
Received: by 10.42.169.67 with SMTP id a3mr2782483icz.8.1334789438876;
Wed, 18 Apr 2012 15:50:38 -0700 (PDT)
X-BeenThere: pylons-discuss@googlegroups.com
Received: by 10.231.2.149 with SMTP id 21ls2026105ibj.5.gmail; Wed, 18 Apr
2012 15:50:31 -0700 (PDT)
Received: by 10.50.214.102 with SMTP id nz6mr2748632igc.4.1334789431734;
Wed, 18 Apr 2012 15:50:31 -0700 (PDT)
Received: by 10.50.213.40 with SMTP id np8msigc;
Wed, 18 Apr 2012 13:28:42 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.95.136 with SMTP id dk8mr3926005igb.0.1334780920992; Wed,
18 Apr 2012 13:28:40 -0700 (PDT)
Authentication-Results: ls.google.com; spf=pass (google.com: domain of
ywxtd.mas...@gmail.com designates internal as permitted sender)
smtp.mail=ywxtd.mas...@gmail.com; dkim=pass
header...@gmail.com
Received: by s10g2000pbc.googlegroups.com with HTTP; Wed, 18 Apr 2012 13:28:40
-0700 (PDT)
Date: Wed, 18 Apr 2012 13:28:40 -0700 (PDT)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3)
AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.163 Safari/535.19,gzip(gfe)
Message-ID: <9ccd4316-d8b1-433c-9e1d-16debef0f3c8@s10g2000pbc.googlegroups.com>
Subject: Best practise of writing send mail console script which sends out
i18n messages
From: ywxtd <ywxtd.mas...@gmail.com>
To: pylons-discuss <pylons-discuss@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
I'm trying to write a batch script, which is scheduled to run every
evening, and it will send out email to users who meet a certain
criteria. The user's language preference is stored in the db, so the
message being sent to users will have translation string. There are
two ways of doing is in my mind:
1. Write a dummy view callable to wrap the email sending logic, use
bootstrap to get the env, then simulate a request to call the view
callable. In this way I can use the global i18n setting which has been
done in the application startup, for example:
pyramid.config.Configurator.add_translation_dirs()
2. The whole logic is in the console script, but I have to setup the
i18n env manually.
Am I doing right or there is better way to implement this?