[Zope-CMF] Re: Removing default from browser:skin layers?

Philipp von Weitershausen philipp at weitershausen.de
Sun Nov 13 00:23:18 EST 2005


Tres Seaver wrote:
> Brent Hendricks wrote:
> 
>>>Tres,
>>>
>>>I'm having trouble with the change you made today taking 'default' out
>>>of the list of layers for the cmf browser:skin in
>>>CMFDefault/skin/configure.zcml.  It seems to cause the views we'e
>>>defined in CMFPlone to no longer be found via the context/@@ lookup in
>>>page templates. I added layer="cmf" to all of the plone view
>>>declarations, but that didn't seem to work.
>>>
>>>Do you any ideas?  In the meantime I defined a 'plone' skin that adds
>>>default back in, but I'd prefer not to do that if it's not supported.
> 
> 
> Likely my bad;  its presence was causing test breakage when running on
> 2.9, so I removed it, intending to investigate why.  Let's put it back,
> with a note in the ZCML documenting the fact that it needs to be checked
> out.

Any skin that wants to take advantage of all the elementary browser
views (such as absolute_url, standard_macros, etc.) should include the
'default' layer because that's what all these views are registered for.
Registering the Plone views for the 'default' layer is perfectly fine;
in Zope 3 you don't need to create new layers for new packages because
layers can be used across packages (unlike in the CMF). In my
experience, Zope 3 layers are usually only used what they were made for:
to customize existing views, IOW, to customize views in the 'default' layer.

Tres, if you're experiencing the test failures with the Zope 2 trunk but
not with Zope 2.8 branch, it might be because your stub request is
lacking the 'default' layer. In Zope 3.1+, layers and skins are
interfaces extending IBrowserRequest and they are directly provided on
the request object by the skin machinery. Five tricks the Zope 2 request
into providing the correct default skin interfaces with the following
code in Traversable.__bobo_traverse__():

        from zope.app.publication.browser import setDefaultSkin
        from zope.app.interface import queryType

        [snip]

        # set the default skin on the request if it doesn't have any
        # layers set on it yet
        if queryType(REQUEST, ILayer) is None:
            setDefaultSkin(REQUEST)

In order to do deal with this (e.g. in tests) in both Zope 2.8 and 2.9
without resorting to ugly try/except clauses, Five could maybe grow a
convenience function to do the above. It would do nothing in Five 1.2
and the above in 1.3. It would go away for Five 1.5.

Let me know if this is the case, I'll be happy to put the function into
Five and release new betas of 1.2 and 1.3.

Philipp



More information about the Zope-CMF mailing list