ポートレットの取得を防止し、portlertを追加する可能性を維持するために、取得を自動的にブロックするコンテンツの作成時にイベントリスナーを追加できます。
<subscriber
for="my.package.interfaces.IMyContent
zope.app.container.interfaces.IObjectAddedEvent"
handler=".subscribers.blockPortletsUpponMyContentCreation"
/>
とこれを行うより:
from zope.component import getMultiAdapter, getUtility
from plone.portlets.interfaces import IPortletManager
from plone.portlets.interfaces import ILocalPortletAssignmentManager
from plone.portlets.constants import USER_CATEGORY
from plone.portlets.constants import GROUP_CATEGORY
from plone.portlets.constants import CONTENT_TYPE_CATEGORY
from plone.portlets.constants import CONTEXT_CATEGORY
def blockPortletsUpponMyContentCreation(mycontent, event):
for manager_name in ('plone.leftcolumn','plone.rightcolumn'):
manager = getUtility(IPortletManager, name=manager_name)
assignable = getMultiAdapter((mycontent, manager,), ILocalPortletAssignmentManager)
for category in (GROUP_CATEGORY, CONTENT_TYPE_CATEGORY,CONTEXT_CATEGORY,USER_CATEGORY):
assignable.setBlacklistStatus(category, 1)
注:このコードはplone.app.portlet manage view
編集19/08/2011に触発さ:提案されているよう修正を含むこのよう
私のテストされていないコードの@willによって...今すぐテストされました
ありがとう!これはまさに私がやりたいことです。将来のユーザー割り当て機能を維持しながら、既存のポートレットをブロックします。私は、portlets.xmlで何かをしようとしていたので、加入者が私に起こっていないと思った。 – Will
後継のために、上記のコードを修正して動作させる必要があります。 ZCMLでは、 'factory'属性は' handler'でなければなりません。マネージャ名はそれぞれ 'IPortletManager'マネージャと' getUtility() 'で一致させる必要があります。 – Will
@あなたはあなたの質問の答えとしてこの答えをマークできますか? – toutpt