Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#598 Getting rid of "Using get_request patch" in the event log

open
nobody
5
2006-08-25
2006-08-25
Josef Meile
No

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

Discussion

  • Josef Meile
    Josef Meile
    2006-08-25

    • assigned_to: longsleep --> nobody