[Zope] Understanding acquisition in CMF/Plone

Chris McDonough chrism@zope.com
05 Aug 2002 22:13:32 -0400


On Mon, 2002-08-05 at 21:39, Phil Glaser wrote:
> Hi,
> 
> I just got done reading about traversal in _The Zope Book_ (pp. 138-140) and
> am at a loss to explain how this is working in Plone. I have a Plone Site
> named "plonetest" and when I go to the user preferences page it brings up
> the following url:
> 
> /proto/testplone/personalize_form
> 
> So Zope is calling the personalize_form method in the context of the
> testplone object. But I can't figure out how personalize_form is being
> acquired. It would be simple if personalize_form were contained in
> testplone, but it's not: there are three versions of personalize_form lower
> down in the hierarchy:

The CMF has the notion of "skins".  If it can't acquire a method from
its context hierarchy, the CMF will ask the "skins tool" (portal_skins)
for a method of the name "personalize_form".  This is purely a feature
of CMF and not of Zope itself... (although it *should* be a Zope feature
;-)

> 
> testplone/portal_skins/generic/personalize_form
> testplone/portal_skins/plone_forms/personalize_form
> testplone/portal_skins/zpt_generic/personalize_form
> 
> >From what I read, I thought that the acquisition mechanism only works from
> lower to higher in the container hierarchy -- that if personalize_form is
> not contained in the testplone object, it just won't be found. But somehow,
> Zope is locating one of these methods and then running against the testplone
> object.  What I read lead me to believe that in order to find an object more
> than one level below the highest container, you would have to include the
> path to the lower container (e.g., portal_skins/generic), or whatever, in
> the url. As a practical matter, I could figure out which form it's calling
> if I could find meaningful differences between the forms, by deduction, but
> that still would not answer my question: How did Zope know which
> personalize_form to call?

It looks at the "portal_skin" cookie for a skin path, or if it doesn't
have one, reverts to a default skin path.  A "skin path" is an ordered
list of skin folders in which it will look one by one for the method. 
You can take a look at this in the "portal_skins" tool inside your CMF
instance.

> 
> Secondarily, for Plone, specifically, the member preferences page lets you
> decide which skin to use, but some  of the names listed (e.g., "plone
> default", "Plone XP") do not appear as distinct folders in the portal_skins
> container. Am I missing something?

Not sure about that...

> 
> 
> Thanks!
> 
> Philip Glaser
> Principal and Software Architect
> Sustainable Software Solutions, LLC
> StillSmallVoice@DirectvInternet.com
> www.sustainsoft.com
> 973-951-9522
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )