[Zope3-Users] Making site skins

Roger Ineichen dev at projekt01.ch
Wed Aug 17 14:14:59 EDT 2005


Hi Johan

On Behalf Of Johan Carlsson
> Sent: Wednesday, August 17, 2005 7:59 PM
> To: Dominik Huber
> Cc: zope3-users at zope.org
> Subject: Re: [Zope3-Users] Making site skins
> 
> 
> Some small success :-)
> 
> I've figured out (thanks to input Dominik, others, and reading the
> source):
> 
> - how to change the current skin
> - how to load a resource from that skin
> 
> The following is currently running in my test View class:
> 
> ns='resource'
> name='test_me.html'
> request=self.request
> object=self.context
> 
> #Look up the skin interface
> adapters = zapi.getSiteManager().adapters
> skin = adapters.lookup((providedBy(self.request),), IDefaultSkin, '')
> skin = zapi.getUtility(ISkin, 'my_test')
> 
> #Change the defaultSkin of the current request
> if skin is not None:
>      directlyProvides(self.request, skin)
> 
> #Get the traversal adapter for the namespace (e.g. resource)
> traverser = zope.component.queryMultiAdapter((object, request), \
>                  ITraversable, ns)
> if traverser is None:
>      raise TraversalError("++%s++%s" % (ns, name))
> 
> #Traverse the resource (e.g. 'test_me.html)
> resource = traverser.traverse(name, ())
> return resource()

Take a look at:
src\zope\app\demo\skinpref

It's a demo how you can use preferences for to switch the skin.
Probably you can use some parts from there.

Regards
Roger Ineichen

Projekt01 GmbH
www.projekt01.ch
_____________________________
END OF MESSAGE 



More information about the Zope3-users mailing list