[Zope-CMF] change skin based on use property

Paul Winkler pw_lists@slinkp.com
Mon, 30 Sep 2002 10:20:15 -0700


On Mon, Sep 30, 2002 at 06:05:22PM +0100, Chris Withers wrote:
> Hi,
> 
> I badly need to set the skin a user sees based on a property of said user.
> How can I do so?

Ack. I tried to do something similar recently (based on roles actually)
and failed. :(

See the thread "Forcing skin by role" from Aug. 22nd.
You can set the skin based on a variable passed in the request
(see http://www.zopelabs.com/cookbook/1028172355 but note
that there's a typo - context.changeSkin(req)
should be something like context.changeSkin("foo_skin")

The problem is that Access Rules are invoked before
the per-page authentication machinery, so you can't even 
find out who the current user is at that moment - you'll always get
Anonymous. 

A workaround would be to have a template which calls changeSkin(), 
and call this template in your header
of all your skins.  I tried this and it kind of works - 
but my skins are not really cross-compatible (e.g. they have some
elements with different names) so I was getting weird things like
looking for spamskin_element within eggskin, and failing because
it didn't exist.  So I think it will work if your skins are
drop-in compatible, i.e. they have elements with all the same names.
But I didn't get far enough with this to really work it out.

--

Paul Winkler
"Welcome to Muppet Labs, where the future is made - today!"