HTTPRequest.__getattr__() fails for key "locale" first time

Bug #1023722 reported by kleist
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope 2
Opinion
Undecided
Unassigned

Bug Description

[copied from http://dev.plone.org/ticket/10875]

Quoting a succesful patch:

from ZPublisher.HTTPRequest import HTTPRequest, _marker

def __getattr__(self, key, default=_marker, returnTaints=0):
    if key == 'locale':
        # we only create the _locale on first access, as setting it
        # up might be slow and we don't want to slow down every
        # request
        if self._locale is _marker:
            self.setupLocale()
        return self._locale
    v = self.get(key, default, returnTaints=returnTaints)
    if v is _marker:
        if key == 'debug':
            return self._debug
        raise AttributeError, key
    return v

HTTPRequest.__getattr__ = __getattr__

Revision history for this message
Hanno Schlichting (hannosch) wrote :

The patch changes behavior in a backwards incompatible way.

In Zope 2 you can have a normal value in the request (or request.form) by the key 'locale'. If you have such a key, the special locale object won't be accessible. We can change this behavior in a new major version like Zope 4 and give the special locale object precedence over normal values. But we cannot do that in a maintenance release.

Changed in zope2:
milestone: none → 4.0a1
status: New → Opinion
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.