Re: [Zope3-Users] Re: Confused about skinning in Zope3

2006-09-17 Thread Albertas Agejevas
On Sun, Sep 17, 2006 at 10:43:39PM +0200, Luis De la Parra wrote:
> Philippe Clérié wrote:
> > a) skins are applied globally and not locally to the packages that own
> > them;
> > 
> > b) skins are not *picked up* unless directly referenced in the URL.
> > 
> > Somehow that does not feel *natural*. Am I missing something?

No, both of these points are correct.

> I'm not sure wether this is the right way to do it, but you can set up the
> skin with a traverse-subscriber:
> 
> 
> def myAppTraverseSubscriber(event):
> """A subscriber to BeforeTraverseEvent.
> 
> Sets the "AC" skin if the object traversed is a "MyApp"
> instance.
> """
> if (IMyApp.providedBy(event.object) and
> IBrowserRequest.providedBy(event.request)):
> applySkin(event.request, AC)

Yep, this is the canonical way to make skins apply to certain kinds of
objects automatically.

Albertas
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Confused about skinning in Zope3

2006-09-17 Thread Luis De la Parra

hello,

I'm not sure wether this is the right way to do it, but you can set up the
skin with a traverse-subscriber:


def myAppTraverseSubscriber(event):
"""A subscriber to BeforeTraverseEvent.

Sets the "AC" skin if the object traversed is a "MyApp"
instance.
"""
if (IMyApp.providedBy(event.object) and
IBrowserRequest.providedBy(event.request)):
applySkin(event.request, AC)

and then in the configure.zcml



with this subscriber you don't have to explicitly set the skin: it will be
set "automatically" when you look up a url inside your application.
Theoretically you could set up the skin for individual objects like this,
but I don't know if it would be practical in real life... setting the skin
on an per-application basis is good enough for me though.

regards. luis


Philippe Clérié wrote:

> Hello list,
> 
> As the title says I am somewhat confused by the skinning system in Zope3.
> I am following the example in "Web Component" (great book by the way) and
> at the time creating another app along the same lines. Now I set up both
> skins for each package and I _expected_ that each would pick up its own
> skin. So a recipe object would show with the worldcookery skin and my app
> would show with its skin (zsoc). Instead it seems that:
> 
> a) skins are applied globally and not locally to the packages that own
> them;
> 
> b) skins are not *picked up* unless directly referenced in the URL.
> 
> Somehow that does not feel *natural*. Am I missing something?
> 
> There's always a chance that I don't have the macros right, but I did copy
> worldcookery/browser/skin, just to make sure I made no mistakes.
> 
> Thanks in advance
> Philippe


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users