[Zope-dev] Re: request.locale

Hanno Schlichting plone at hannosch.info
Fri Sep 7 18:47:55 EDT 2007


Laurence Rowe wrote:
> Quite a lot of zope3 code (zc.datetimewidget for instance) expects to be
> able to access request.locale. ZPublisher does not provide this and to
> get around the limitation you must manually set request.locale in your
> view using Products.CMFDefault.formlib.form.getLocale. This seems
> brittle. I think it would be desirable to include such functionality in
> Zope 2. If there is support for this, where should it go?
> ZPublisher.HTTPRequst or somewhere in Five seem like prime candidates.

My suggestion on this would be to make request.locale available in Zope
2.11. It would not be available through any of the other means like
request['locale'] or request.form['locale'] but just as a simple
property on the request itself.

You would still be able to override it, but the set method for it would
emit a deprecation warning telling you that you should not use this
specific name anymore.

The only backward incompatible change this would introduce from what I
can tell is that checking for the presence of request.locale would
suddenly give you a true value whereas it would have raised an error
before. Given the unlikelihood of this and the major benefit of being
able to use more unchanged Zope3 code, I personally would find this
acceptable.

Hanno



More information about the Zope-Dev mailing list