Did not find a how-to for your problem?

Ask me to write the how-to post by writing to the mailing-list at cps-devel [@] lists [.] nuxeo [.] com or writing to me to joseluisdelarosa+cpshowto [@] gmail [.] com. Note: I'll keep all conversations on the official mailing list.

Monday, June 11, 2007

How to build an action provider

Almost every link of CPS that let's you do a change on a document is called an action in CMF's jargon.

This post will deal with how to add a tab to the tool portal_imessages so that it allows to define its own actions. Let's start:

  1. Declare our tool as action provider:


    from Products.CMFCore.ActionProviderBase import ActionProviderBase
    ...
    ...
    class MessagesTool(SimpleItem, PropertyManager, ActionProviderBase):


  2. Declare the “Actions” tab by creating adding a new item to the attribute manage_options.


    manage_options = (
    PropertyManager.manage_options
    + SimpleItem.manage_options
    + ActionProviderBase.manage_options
    )


  3. Create the profile specification of the action provider with the list of actions. Add these lines to the actions.xml file.



    <action-provider name=”portal_imessages”>
    <action title="action_send_msg"
    action_id="action_send_msg" category="object"
    condition_expr="python:not portal.portal_membership.isAnonymousUser()"
    url_expr="string:${portal/portal_url}/send_message" visible="True">
    <permission>Modify portal content</permission>
    </action>
    </action-provider>


  4. Add the step actions to import_steps.xml.



    <import-step id="actions" version="20040630-01"
    handler="Products.CMFCore.exportimport.actions.importActionProviders"
    title="Action Providers">
    <dependency step="toolset"/>
    Import actions tool's action providers and their actions.
    </import-step>


    Don't relax!! It's almost done...

  5. Restart Zope's instance

  6. Go to portal_setup tool and import the profile CPS Messages

  7. Go to the tool portal_imessages and you should see the tab Actions.


I'll be waiting for your comments of success... ;-)

No comments: