基於敏捷的內容類型的工廠類型信息(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