Manipulating cookies after sending response on Plone 4.3

56 views Asked by At

I need to change data stored inside cookies, or set new cookies when a user access a Plone URL.

The official Plone documentation contains exactly what I need in the Modifying HTTP response cookies section.

Unluckily it seems to be a deprecated documentation as it's need the plone.postpublicationhook package, not shipped with Plone and only needed For Zope < 2.12; documentation says: "This package is provided for backwards compatibility. New code should use the publication events introduced in Zope 2.12 directly."

As I'm using Plone 4.3/Zope 2.13 I'm wondering if there's a way to do not include this deprecated package.

I'm trying to use the ZPublisher.interfaces events without any success.

I'm trying a ZCML registration like this:

  <adapter
      factory=".mymodule.my_cookie_handler_function"
      provides="ZPublisher.interfaces.IPubSuccess"
      />

But the function is never called.

Some examples/codes I found (but still can't reach my scope):

1

There are 1 answers

1
keul On BEST ANSWER

Although I see code that's use adapters, it seems you must provide a subscriber instead.

This worked:

  <subscriber
      handler=".mymodule.my_cookie_handler_function"
      for="ZPublisher.interfaces.IPubSuccess"
      />

Not sure if IPubSuccess is the "right" interface to use.