Best practise of writing send mail console script which sends out i18n messages

21 views
Skip to first unread message

ywxtd

unread,
Apr 18, 2012, 4:28:40 PM4/18/12
to pylons-discuss
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?
Reply all
Reply to author
Forward
0 new messages