[Product-Developers] know folderish types

Nathan Van Gheem vangheem at gmail.com
Mon May 28 13:47:23 UTC 2012


You can do something like this, but it's probably not an operation
you'll want to perform often. This is pseudo code...

import transaction
import random
from Products.CMFCore.interfaces._content import IFolderish
site = app.Plone
portal_types = site.portal_types
savepoint = transaction.savepoint()
folder_types = []
for type_info in portal_types.objectValues():
  ob = type_info._constructInstance(site, str(random.randint(9999))
  if IFolderish.providedBy(ob):
    folder_types.append(ob.portal_type)
savepoint.rollback()


The reason this is difficult is because portal_types doesn't register
an actually class for the object to be constructed--it only registers
a factory method.

This all might be little silly though. Default plone ships with only a
couple folder types--only 1 the user uses(Folder). Anything extra is
likely to be custom so you should know what the folderish types are
from that.


On Mon, May 28, 2012 at 8:21 AM, Alejandro Pereira
<alepereira86 at gmail.com> wrote:
>> 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.
>
>
> This methods are util if context is an object of some folderish content
> type. This is not what i
> look for. The reason of that is because maybe the site where the code is
> running doesn't
> have objects yet of some folderish types. What i'm looking for is, in this
> case how do you know
> what types are folderish? what methodology will be useful to know this if
> you haven't yet
> create objects of all your folderish types?
>
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-product-developers
>


More information about the Product-Developers mailing list