Testing for a provided interface from within a page template

4 messages Options
Embed this post
Permalink
J-C Brand () Testing for a provided interface from within a page template
Reply Threaded More More options
Print post
Permalink
Hi Devs,

I'm adding a custom CMF Action for my subtype enhanced archetype.

In the actions.xml there is a property "available_expr" in which I can
specify a guard condition for when to show this action.

This expression will render inside a page template, so it can either be
a tales expression, or a python expression restricted to the page
template environment.

So, the question is, how can I test that an object is subtyped, or that
an object provides a certain interface from within a page template?

Thanks!
J-C

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Hedley Roos () Re: Testing for a provided interface from within a page template
Reply Threaded More More options
Print post
Permalink
> So, the question is, how can I test that an object is subtyped, or that
> an object provides a certain interface from within a page template?

portal_catalog has a Keyword Index object_provides which you can query
from a page template. A subclass automatically inherits a super class's
interfaces.

Hedley

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Mikko Ohtamaa () Re: Testing for a provided interface from within a page template
Reply Threaded More More options
Print post
Permalink
In reply to this post by J-C Brand

J-C Brand wrote:
In the actions.xml there is a property "available_expr" in which I can
specify a guard condition for when to show this action.

This expression will render inside a page template, so it can either be
a tales expression, or a python expression restricted to the page
template environment.

So, the question is, how can I test that an object is subtyped, or that
an object provides a certain interface from within a page template?
I suggest you create a BrowserView which does the complex expression code in Python.

Please see http://plonemanual.twinapex.fi/content/expressions.html "Custom expression code"

--
Mikko Ohtamaa
http://www.twinapex.com - Python professionals for hire
J-C Brand () Re: Testing for a provided interface from within a page template
Reply Threaded More More options
Print post
Permalink
Mikko Ohtamaa wrote:

>
> J-C Brand wrote:
>  
>> In the actions.xml there is a property "available_expr" in which I can
>> specify a guard condition for when to show this action.
>>
>> This expression will render inside a page template, so it can either be
>> a tales expression, or a python expression restricted to the page
>> template environment.
>>
>> So, the question is, how can I test that an object is subtyped, or that
>> an object provides a certain interface from within a page template?
>>
>>    
>
> I suggest you create a BrowserView which does the complex expression code in
> Python.
>
> Please see http://plonemanual.twinapex.fi/content/expressions.html "Custom
> expression code"
>  

Thanks, worked like a charm.

By the way, great job on the developers manual!



_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers