[Zope-CMF] change skin based on use property

sean.upton@uniontrib.com sean.upton@uniontrib.com
Mon, 30 Sep 2002 11:33:12 -0700


Yuck; it would really be nice if there was a way to do this within an access
rule, even if some sort of sessioning/cookie/whatever machinery had to be
used?

I'm using the toggleSkin recipe (below) for host-based skins, which works
nicely, provided you use Skinnable.py and SkinsContainer.py from CVS; I know
that in the future, however, I will need to have some sort of machinery to
do skin personalization like this based upon user properties or roles.
Hopefully there is something more graceful (I really don't want to have to
have to put the heavy lifting inside the skin methods?)...

Quick, unrelated question for the list: does anyone know if an external
method is going to have a measurably significant performance advantage over
using a TTW Python script for an access rule?

Sean

-----Original Message-----
From: Paul Winkler [mailto:pw_lists@slinkp.com]
Sent: Monday, September 30, 2002 10:20 AM
To: Zope-CMF@zope.org
Subject: Re: [Zope-CMF] change skin based on use property


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!"

_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests