[Greg Ward]
>
> What code do you have now, and precisely how does it not work?
It's kind of ugly at this point. But what the heck. Here is where I'm
retrieving the cookie:
SHEETS = {
'chocolate': 'http://www.w3.org/StyleSheets/Core/Chocolate.css',
'default': '/www/css/orbtechweb.css',
'midnight': 'http://www.w3.org/StyleSheets/Core/Midnight.css',
'modernist': 'http://www.w3.org/StyleSheets/Core/Modernist.css',
'oldstyle': 'http://www.w3.org/StyleSheets/Core/Oldstyle.css',
'steely': 'http://www.w3.org/StyleSheets/Core/Steely.css',
'swiss': 'http://www.w3.org/StyleSheets/Core/Swiss.css',
'traditional': 'http://www.w3.org/StyleSheets/Core/Traditional.css',
'ultramarine': 'http://www.w3.org/StyleSheets/Core/Ultramarine.css',
}
def getCSS(request=None):
styles = SHEETS
default = '/www/css/orbtechweb.css'
if request is None:
return default
style = request.cookies.get('style')
if style is None:
return default
css = styles.get(style, default)
return css
That part works, but only in the sense that I always get the default, never
the cookie. 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):
_q_exports = []
def _q_index(request):
return """\
The Styles
You have these styles:
"""
def _q_getname(request, component):
return Style(request, component)
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)
It also "works" in that the index page displays properly for
'http://orbtech.com/style/' and I also see the index page for a particular
style, such as 'http://orbtech.com/style/swiss/' so I know that a Style
object is being created and the __init__ is executing. (Because self.style
resolves properly in _q_index when it displays a page saying "You have
selected swiss", for example.) But again, the cookie stuff doesn't work and
I see no cookie being created on my machine. Plenty of other sites create
cookies on my machine just fine.
I do have some level of security set (this is IE on Win98), but I
specifically allow all cookies from my local machine and from my website. So
I don't think it is a security issue.
I'm stumped. See anything obvious?
---
Patrick K. O'Brien
Orbtech