Derek Broughton wrote:
I've been banging my head on this for a day, and it's time to ask for help.
Martin's borg.project has the following code (simplified here) which works
fine for Archetypes:
portal_types = getToolByName(context, 'portal_types')
for fti in portal_types.listTypeInfo():
factory = getattr(fti, 'factory', None)
product = getattr(fti, 'product', None)
dispatcher = getattr(context, 'manage_addProduct', None)
product_instance = dispatcher[product]
factory_method = getattr(product_instance, factory, None)
factory_instance = getattr(factory_method, 'im_self', None)
factory_class = factory_instance.__class__
role_permission = getattr(factory_class, factory+'__roles__', None)
Unfortunately, non-archetype content (borg.project included) doesn't have a
"product", and I can't find any way to find a corresponding PermissionRole
object for those.
Mmmm.... I'm not sure how this works, but I have a better idea:
http://plone.org/products/dexterity/documentation/manual/developers-manual
:-)
Dexterity has an explicit add permission in the FTI, which is checked by
the FTI isContructionAllowed.
That code in borg.project is kind of evil. I don't know a a better way
to find "the add permission" of an object.
I think you'd need to figure out what five:registerClass or does with
the add permission you give. Or maybe they're all "Add portal content"
by default?
[I do wish you'd made "default_addable_types" a utility, Martin...]
I didn't know what a utility was back then, and I'm not sure this is
even my code. I think it was Tiran. :-)
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers