On 28 May 2002, Patrick K. O'Brien said:
> It's kind of ugly at this point. But what the heck. Here is where I'm
> retrieving the cookie:
[...cookie-reading code omitted...]
> That part works, but only in the sense that I always get the default, never
> the cookie.
Have you tried submitting a hand-crafted request with just the right
cookie, eg:
$ telnet localhost 80
GET / HTTP/1.0
User-agent: me
Cookie: style=swiss
? Look at the response and see if your cookie is having the expected
result.
> But I think that is because the cookie isn't getting set. The
> way I set the cookie is a bit different than your examples. I didn't use a
> form. Instead I have another module so that I can set the style using a URI
> like 'http://orbtech.com/style/swiss/'. Here's that module (named style.py):
Clever. That should work too.
[...]
> class Style:
> """Cascading Style Sheet support."""
> _q_exports = []
>
> def __init__(self, request, component):
> self.style = component
> request.response.set_cookie('style', component)
>
> def _q_index(self, request):
> return """\
>
> %s
>
> You have selected %s.
>
>
> """ % (self.style, self.style)
Yep, that looks sensible. (As an aside, you'll be able to ditch the
class and do all this directly in _q_getname() in Quixote 0.5.)
Actually, your use of URLs instead of forms makes it a bit easier to
debug. Another hand-crafted request:
$ telnet localhost 80
GET /style/swiss/ HTTP/1.0
...and look for the Set-cookie header in the response. If it's there,
Quixote is working fine and your browser is not. If it's not there,
start putting debug prints into your code and into Quixote (most likely
http_response.py) to see what it's doing. Tail the debug log and see
what happens.
Oh yeah: look for "domain" and "path" attributes in that Set-Cookie
header. It could be that both Quixote and your browser are acting
correctly, and you just need to set COOKIE_DOMAIN and/or COOKIE_PATH in
your config file. (NB. this is yet another thing that will changed with
Quixote 0.5!)
still-mystified-why-people-try-to-do-web-development-under-windows,
Greg
--
Greg Ward - software developer gward@mems-exchange.org
MEMS Exchange http://www.mems-exchange.org