Created
August 29, 2012 20:10
-
-
Save jensens/3518210 to your computer and use it in GitHub Desktop.
Plone action menu enable feature by setting marker interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zope.interface import Interface | |
from zope.interface import directlyProvides | |
from zope.interface import noLongerProvides | |
from Products.Five.browser import BrowserView | |
from Products.CMFPlone import PloneMessageFactory as _ | |
class ISomeFeatureTarget(Interface): | |
pass | |
class IPossibleSomeFeatureTarget(Interface): | |
pass | |
class ActionsView(BrowserView): | |
def enableSomeFeatureTarget(self): | |
directlyProvides(self.context, ISomeFeatureTarget) | |
self.context.portal_catalog.reindexObject(self.context, | |
idxs=['object_provides'], | |
update_metadata=1) | |
self.context.plone_utils.addPortalMessage( | |
_(u'Enabled SomeFeature Target.')) | |
self.request.response.redirect(self.context.absolute_url()) | |
def disableSomeFeatureTarget(self): | |
noLongerProvides(self.context, ISomeFeatureTarget) | |
self.context.portal_catalog.reindexObject(self.context, | |
idxs=['object_provides'], | |
update_metadata=1) | |
self.context.plone_utils.addPortalMessage( | |
_(u'Disabled SomeFeature Target.')) | |
self.request.response.redirect(self.context.absolute_url()) | |
def isPossibleToEnableSomeFeatureTarget(self): | |
return IPossibleSomeFeatureTarget.providedBy(self.context) \ | |
and not ISomeFeatureTarget.providedBy(self.context) | |
def isPossibleToDisableSomeFeatureTarget(self): | |
return IPossibleSomeFeatureTarget.providedBy(self.context) \ | |
and ISomeFeatureTarget.providedBy(self.context) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configure xmlns="http://namespaces.zope.org/zope" | |
xmlns:browser="http://namespaces.zope.org/browser" | |
xmlns:five="http://namespaces.zope.org/five"> | |
<five:implements | |
class="Products.Archetypes.BaseObject.BaseObject" | |
interface=".actions.IPossibleSomeFeatureTarget" /> | |
<browser:page name="enable-SomeFeaturetarget" | |
attribute="enableSomeFeatureTarget" | |
for=".actions.IPossibleSomeFeatureTarget" | |
class=".actions.ActionsView" | |
permission="cmf.ManagePortal" | |
layer=".layer.IMyFeatureExtensionLayer" | |
/> | |
<browser:page name="disable-SomeFeaturetarget" | |
attribute="disableSomeFeatureTarget" | |
for=".actions.IPossibleSomeFeatureTarget" | |
class=".actions.ActionsView" | |
permission="cmf.ManagePortal" | |
layer=".layer.IMyFeatureExtensionLayer" | |
/> | |
<browser:page name="is-possible-to-enable-SomeFeaturetarget" | |
attribute="isPossibleToEnableSomeFeatureTarget" | |
for="*" | |
class=".actions.ActionsView" | |
permission="cmf.ManagePortal" | |
layer=".layer.IMyFeatureExtensionLayer" | |
/> | |
<browser:page name="is-possible-to-disable-SomeFeaturetarget" | |
attribute="isPossibleToDisableSomeFeatureTarget" | |
for="*" | |
class=".actions.ActionsView" | |
permission="cmf.ManagePortal" | |
layer=".layer.IMyFeatureExtensionLayer" | |
/> | |
</configure> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<object name="portal_actions" meta_type="Plone Actions Tool" | |
xmlns:i18n="http://xml.zope.org/namespaces/i18n"> | |
<object name="object_buttons" meta_type="CMF Action Category"> | |
<object name="enableMyFeatureTarget" | |
meta_type="CMF Action" | |
i18n:domain="bda.plone.spiegelnavi"> | |
<property name="title" i18n:translate=""> | |
Enable MyFeature Target | |
</property> | |
<property name="description" i18n:translate=""> | |
Activate as MyFeature Target | |
</property> | |
<property name="url_expr"> | |
string:${object/absolute_url}/@@enable-MyFeaturetarget | |
</property> | |
<property name="icon_expr"></property> | |
<property name="available_expr"> | |
object/@@is-possible-to-enable-MyFeaturetarget | |
</property> | |
<property name="permissions"> | |
<element value="Manage portal" /> | |
</property> | |
<property name="visible">True</property> | |
</object> | |
<object name="disableMyFeatureTarget" | |
meta_type="CMF Action" | |
i18n:domain="bda.plone.spiegelnavi"> | |
<property name="title" i18n:translate=""> | |
Disables MyFeature Target | |
</property> | |
<property name="description" i18n:translate=""> | |
Deactivates as MyFeature Target | |
</property> | |
<property name="url_expr"> | |
string:${object/absolute_url}/@@disable-MyFeaturetarget | |
</property> | |
<property name="icon_expr"></property> | |
<property name="available_expr"> | |
object/@@is-possible-to-disable-MyFeaturetarget | |
</property> | |
<property name="permissions"> | |
<element value="Manage portal" /> | |
</property> | |
<property name="visible">True</property> | |
</object> | |
</object> | |
</object> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment