- assigned_to: longsleep --> nobody
Hi,
I'm using PTS programatically from my product as follows:
def useTranslationService(context, domain, msgid, \
*args, **kw):
"""Uses the TranslationService from python"""
PTS=context.Control_Panel.TranslationService
translation=PTS.translate(domain,msgid,*args,**kw)
return translation
But I always get this in the event log:
"PlacelessTranslationService Using get_request patch"
Two solutions I could think about was to manually
delete the warning inside the _getContext method, which
works, but since I want to redistribute my Product, I
don't want to tell the users to do this step manually.
The other solution I could find was to rewrite the
whole _getContext inside my method, but without the
warning:
def useTranslationService(context, domain, msgid, \
*args, **kw):
"""Uses the TranslationService from python"""
PTS=context.Control_Panel.TranslationService
translation=PTS.translate(domain,msgid,*args,**kw)
PTSCtxt = getattr(context, 'REQUEST', context)
if not isinstance(PTSCtxt, HTTPRequest):
try:
from Globals import get_request
except ImportError:
from PatchStringIO import applyRequestPatch
applyRequestPatch()
else:
PTSCtxt = get_request()
kw['context'] = PTSCtxt
translation=PTS.translate(domain,msgid,*args,**kw)
return translation
which indeed works. However, I think calling the
_getContext directly would be much better. So, why
don't you add a flag to such method "log_to_zope" that
defaults to True. Then I could call it like:
PTSCtxt = PTS._getContext(context,log_to_zope=False)
The other option would be to remove the warning from
future releases.
Regards
Josef