[Zope3-Users] Making site skins

Johan Carlsson johanc at easypublisher.com
Wed Aug 17 13:59:02 EDT 2005


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()


Cheers,
Johan

-- 
Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: johanc at easypublisher.com
SE-113 37 STOCKHOLM



More information about the Zope3-users mailing list