[Erp5-dev] a patch for Localizer patch
Jérôme Perrin
jerome at nexedi.com
Fri Dec 22 17:12:32 CET 2006
Le Jeudi 21 Décembre 2006 16:39, Bartłomiej Górny a écrit :
> Hello
>
> There is sometimes a problem with GlobalTranslationService - in
> ERP5Type/patches/Localizer.py it relies on acquisition to find the
> Localizer object. But if we are processing an email received by zope, we
> are in context of ZMailIn instance, and Localizer can't be found.
>
> So we should either do the simplest thing possible - return untranslated
> message:
>
> Index: ERP5Type/patches/Localizer.py
> ===================================================================
> --- ERP5Type/patches/Localizer.py (rĂŠvision 11733)
> +++ ERP5Type/patches/Localizer.py (copie de travail)
> @@ -83,9 +83,13 @@
> if context is None:
> # Placeless!
> return msgid
> + # XXX patch -because if context is ZMailIn, it is at the site root
> + # and does not find Localizer by acquisition
> + try:
> + return context.Localizer.translate(domain, msgid, *args, **kw)
> + except AttributeError:
> + return msgid
I'd prefer that we don't hide the exception here.
* this Localizer is registred as GlobalTranslationService for all
i18n:translate in page templates, so if one doesn't have a Localizer object,
it will be a real pain to find out why no translation happen :)
* today, Products.ERP5Type.Message doesn't work in activities with
TimerService, because TimerService's requests
traverse /Control_Panel/timer_service/process_timer, and do not have a
Localizer in REQUEST['PARENTS']
So before we have a clean way to register translation service, I think we
should add a LOG('ERP5Type.patches.Localizer', ERROR, 'Cannot find a
Localizer object in acquisition context, message was not translated')
BTW, I found this in my /etc/postfix/aliases, IIRC I was using CMFMailin, not
ZMailin directly.
mailin: |"erp5mailin:
|"/usr/bin/python /usr/lib/zope/lib/python/Products/CMFMailIn/sendMailToZope.py
http://user:pwd@127.0.0.1:9080/erp5/portal_mailin"
Jérome
More information about the Erp5-dev
mailing list