Ok, I got it to work, I needed to use restrictedTraverse() and to give
it a default value of False, which would suppress the Unauthorized
exception and just return False:
checkPermission('View', portal.restrictedTraverse('<some path>', default=False))
I still have a bit of a concern about the cost associated with having
this kind of 'full object' check for multiple tabs, as it takes the
restrictedTraverse() hit on every page request. But I'm not aware of
any other way to get this behavior.
Thanks for the help!
-hoss
On Mon, Jul 27, 2009 at 12:18, David Hostetler<[email protected]> wrote:
> Thanks for the tip -- unrestrictedTraverse() seems like a viable approach.
>
> However, my first attempt caused an unexpected issue: using an
> expression like the one you provided, as the condition for the action
> in portal_actions/portal_tabs, caused an 'Unauthorized' exception to
> be raised.
>
> using restrictedTraverse() didn't change the behavior.
>
> Do I need to push this down into an external method, so that I can use
> unrestrictedTraverse()?
>
> It seems like just attempting to get the object so that I can apply
> the checkPermission() test on it, causes the same permission exception
> that I'm trying to test for in the first place. Bit of a
> chicken-and-egg scenario.
>
>
> thanks,
>
> -hoss
>
>
> On Mon, Jul 27, 2009 at 05:01, Gilles
> Lenfant<[email protected]> wrote:
>>
>> This is not the solution for David. This just asserts that the user has the
>> View permission on the context object and *not* on the link target object.
>>
>> If your target is "string: $portal_url/some/path", then the condition should
>> be:
>>
>> "python:checkPermission('View', portal.unrestrictedTraverse('/some/path')"
>>
>> HTH
>> --
>> Gilles Lenfant
>>
>
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers