Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Setting get_localizer as a property of request causes infinite loop. #508
With the introduction of
@subscriber(NewRequest) def request_i18n(event): request = event.request request.set_property(get_localizer, 'localizer', reify=True)
Unfortunately, this causes an infinite recursive loop, because get_localizer() begins with:
def get_localizer(request): """ Retrieve a :class:`pyramid.i18n.Localizer` object corresponding to the current request's locale name. """ localizer = getattr(request, 'localizer', None) ...
Which of course results in the function calling itself over and over. With the codebase as it is, the current options seem to be:
(Or wrap in a function that passes a dummy request, and then return the localizer from that, but that's awfully hackish.)
In tracking this down I noticed that the TODO file has this listed in the nice-to-haves:
Which I absolutely agree would be nice, as it looks like it is not currently possible to do this cleanly on the user side of the framework, with the most seemingly reasonable path towards it resulting in an infinite loop.