Reputation: 73
I've created a custom type dexterity, in Plone 4.3.9, called PersonalPage that must be only allowed in a specific folder Members_folder/userfolder .
In his FTI, by default <property name="global_allow">False</property>
.
The userfolder is created in Members_folder with the uid of the authenticated user, in Plone 4.3.3:
if homefolder is None:
# create userfolder in members_folder
members_folder.invokeFactory('Folder', user_id)
userfolder = members_folder[user_id]
utils = userfolder.plone_utils
utils.changeOwnershipOf(userfolder, user_id,
1, None)
userfolder.setCreators([user_id])
roles = list(userfolder.get_local_roles_for_userid(user_id))
if 'Owner' not in roles:
roles.append('Owner')
userfolder.manage_setLocalRoles(user_id, roles)
if shasattr(userfolder, 'canSetConstrainTypes'):
userfolder.setConstrainTypesMode(1)
defaultAllowedTypes = userfolder.getLocallyAllowedTypes()
userfolder.setLocallyAllowedTypes(defaultAllowedTypes + ('personalpage',))
defaultAddableTypes = userfolder.getImmediatelyAddableTypes()
userfolder.setImmediatelyAddableTypes(defaultAddableTypes + ('personalpage',))
userfolder.reindexObjectSecurity()
userfolder.reindexObject()
But after running this script the content type PersonalPage doesn't appear in the list of the addable and allowed contents types of the userfolder. What's wrong with this? Is there another way to allowed a content type addable only for a folder?
Upvotes: 4
Views: 168
Reputation: 7819
The script is not not working because of the global_allow flag.
Plone has 2 level of content type add restriction:
If you need to limit addable types for a single folder you can define your folder as a new special type, used only once in the site (so keep global_allow true, create one folder, then disable it); finally specify PersonalPage as one of the allowed_types inside it and keep keep your global_allow settings for PersonalPage to False.
Alternatively you can use collective.factorymenu, to modify Plone add menu through the web (is not released yet but is working).
Upvotes: 4