[Zope3-dev] quoting cookies
Tres Seaver
tseaver@zope.com
20 Feb 2003 10:50:45 -0500
On Thu, 2003-02-20 at 10:45, Steve Alexander wrote:
> Shane Hathaway wrote:
> > Tres Seaver wrote:
> >
> >> class IHTTPCookieQuoter(Interface):
> >> def quoteCookie(mapping):
> >> """ mapping->string.
> >>
> >> o Applies appropriate quoting.
> >> """
> >>
> >> Then, in ZCML:
> >>
> >> <utility component=".utilities.cookie_quoter"
> >> provides=".IHTTPCookieConverter"
> >> />
> >>
> >> People who want to change the policy then do it via configuration,
> >> rather than code.
> >
> >
> > Is there any reason people would want to change the policy?
>
> If you want to interoperate with another system that uses its own
> quoting policy, under the same host name.
>
> However, I think in this case, you should use the setCookie(raw=True)
> API, and use your own wrapper function in code.
>
> If you're interoperating like this, then the nature of your cookies
> already depends on that other system. So, there's no benefit in
> extracting the quoting policy into a general adapter.
A utility, not an adapter (there is no "source" interface to adapt).
This is precisely the case I had in mind: some other sever (e.g.,
'mod_usertrack') will be setting / using the cookie, and you want Zope
to "play nice" with it. In that case, you would wire in a different
implementation of the utility. Most people would never change the
default version.
> I don't actually have the requirement to interoperate in this way.
Requiring people to change Python code to change policies seems like an
"anti-use-case" for the component architecture. I am therefore -1 on a
"raw" parameter to the 'setCookie' API.
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com