[Zope-CMF] need to link one folder from another

Shane Hathaway shane@zope.com
Mon, 21 Apr 2003 09:42:07 -0400


Dieter Maurer wrote:
> Dieter Maurer wrote at 2003-4-17 19:57 +0200:
>  > ... "Reference" not working as skin name source ...
>  >  ....
>  >  >  > And the skin folders/references are definately not getting picked up by
>  >  >  > portal_skins.
>  >  > 
>  >  > They do in my test.
>  > 
>  > Sorry, I was wrong!
>  > I made a mistake in my test.
>  > 
>  > I will investigate why the reference does not work as expected.
> 
> I have bad news:
> 
>   A "Reference" will not work correctly as name source for a skin.
> 
> 
> The reason is given by the comment to the "Reference.__of__" method:
> 
>         # DM: Acquisition is a really interesting thing!
>         #     when "__of__" is called for the first time, "parent" is
>         #     still unwrapped and "restrictedTraverse" will fail
>         #     therefore, we check for it and return "self" in this case
>         #     Usually, we will be called a second time, and this time
>         #     "parent" is wrapped and we return the result.
> 
> 
>   A "SkinsContainer" (such as "portal_skins") does not follow
>   the usual pattern for "__of__" calling.
> 
>   When a reference is the last part in the skin path, both calls to "__of__"
>   are with unwrapped parent objects and the reference cannot find
>   its target.
> 
>   When the reference is not the last path, the second call of "__of__"
>   is wrapped but the acquisition context is cut at the
>   skins container. Therefore, the "restrictedTraverse" will
>   fail unless the reference points to an object below this
>   skins container.
> 
> There is nothing, "Reference" could do to work around this problem.

FYI: This is by design.  If CMF allowed you to use objects outside 
portal_skins as skins, it would open up a large security hole.  Both for 
security and for speed, CMF cuts off acquisition at the skins tool. 
References can't get around that.

Shane