[Product-Developers] know folderish types

Sean Upton sdupton at gmail.com
Fri May 25 18:51:39 UTC 2012

On Fri, May 25, 2012 at 7:48 AM, Alejandro Pereira
<alepereira86 at gmail.com> wrote:
> Basically what i need to do is to make a list of all availables folderish
> content type in
> the site and i'm having trouble to do it. The first way that i thought was
> getting the FTI
> of each one and try to get some info from it telling me that the type is
> folderish but i think
> my guess was wrong.

Use IFolderish.providedBy(aq_base(context)) or
aq_base(context).isPrincipiaFolderish attribute on the item from
*unrestricted) Python and portal_interface tool from everywhere else
to check against IFolderish.

> Seeing some blogs and stuff through the web, i can only see one way to know
> that and
> it is creating a type object and inspect if that one provides the interface
> IFolderish from
> Products.CMFCore.interfaces._content. But this way is extremely awful and
> inefficient.

I really don't imagine that using the portal_interface tool (from
TALES expessions in actions, workflow, and menus) is inefficient.

> To reduce that inefficiency I thought maybe in create a utility that store
> the info of folderish
> and not-foldersih content types and then make a consult when i need to. But
> still is not
> convincing me.

You could, but it will not be faster than checking an interface using
portal_interface or using IFolderish.providedBy().  Given the utility
lookup, even if you memoized this on the utility per type, you still
end up with the overhead of looking up the utility.

> Is there a better, faster and formal way to do this?

Directly checking isPrincipiaFolderish attribute is likely to be the
quickest, but likely less favorable than checking for IFolderish.


More information about the Product-Developers mailing list