基于敏捷的内容类型的工厂类型信息(FTI)在plone.dexterity/plone/dexterity/fti.py
中声明了添加许可权属性,但没有编辑权限属性。
如果您只是要求,为管理员授予添加权限并且不需要进一步优化,您实际上不需要定义新的权限,只需将其立即授予管理员,如下所示:
<property name="add_permission">cmf.ManagePortal</property>
对于允许编辑只经理,我会阻止本地权限的分配的继承与这条线在你的contentType的类声明:
class YourDexterityContenttypeClassName(dexterity.Item): __ac_local_roles_block__ = True
但是,这也会阻止继承的查看和查看权限。如果你需要照顾这些分开过,另一种方法是添加上创造你的contentType中的事件监听,检查继承的角色,并删除它的编辑角色:
from Acquisition import aq_inner
def blockEditors(obj, event):
""" Remove possibly inherited editor-role.
"""
context = aq_inner(obj)
editors = context.users_with_local_role('Editor')
# For any editor:
for editor in editors:
# Get her local-roles:
roles = list(context.get_local_roles_for_userid(editor))
# Subtract editor-role of roles:
roles.remove('Editor')
# Set roles (the old roles without editor):
context.manage_setLocalRoles(editor, roles)
# Update changes:
context.reindexObjectSecurity()
管理者可以编辑自己的无论如何默认情况下,contenttypes拥有全局修改权限。
注意:这是昂贵的调用,并且此示例仅查找用户分配,您可能必须扩展此示例以查找分配的组。
我想最好的方法是为您的类型创建一个自定义工作流程。在此工作流程中,您只允许网站管理员“Mofify门户内容”和“添加您的内容类型”。 – Mathias