Hi,

I've developed a BrowserView that does 2 things:

   1. it sets a cookie
   2. it redirects the browser back to the previous page

Everything works without problems when I test it in a browser. But now I
want to write doctests for it.
I simulate a browser-session with zope.testbrowser, and go to my view. I get
a "HTTP Error 302" back
(as expected), and the headers also seem fine (ie. there is a Set-Cookie
header):

Go to my view::

    >>> link = browser.getLink("My view")
    >>> link.click()  # doctest: +ELLIPSIS
    Traceback (most recent call last):
    ...
    HTTPError: HTTP Error 302: Moved Temporarily

Check the headers::

    >>> for header in browser.headers.headers:
    ...     print header.replace("\x00", "")
    Status: 302 Moved Temporarily
    Content-Length: 0
    Location: http://nohost/plone
    Set-Cookie: my_cookie="hello"; Path=/

But here the test-browser just stops. I don't get redirected to the previous
page, and
the cookie isn't actually set. The mechanize-part seems to work, the
HTTPRedirectHandler
is called, but I don't seem to get the results back. Is there something I'm
doing wrong?


--
Bert Vanderbauwhede
--
"I don't know if you noticed or not, but I'm an extremely arrogant man, who
thinks all his plans will work."
Rodney McKay, Stargate Atlantis
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to