- Create a file MessagesTool.py in the folder CPSMessages like this:
# Python modules
import logging
# Third-party modules
from OFS.SimpleItem import SimpleItem
# This product's modules
# Global variables
logger = logging.getLogger('CPSMessages.MessagesTool')
class MessagesTool(SimpleItem):””””””id = "portal_imessages"meta_type = "MessagesTool" - Register the tool in the file __init__.py of the product by adding the import of the class ToolInit and the ToolInit method to initialize procedure.
from Products.CMFCore.utils import ToolInit
import MessagesTool
def initialize(context):""""""ToolInit('Messages Tool',tools=(MessagesTool.MessagesTool,),icon='tool.png',).initialize(context)
The class ToolInit needs the name of the new tool, a list of tools to register and the filename of an icon. - Copy the icon called tool.png from any other product or create your own, it can be a .gif too.
- Add a new step in the file import_steps.xml (path CPSMessages/profiles/default) to import tools. The new file looks like this:
<?xml version="1.0"?>
<import-steps><import-step id="toolset" version="20040630-01"handler="Products.GenericSetup.tool.importToolset"title="Required tools">Create required tools, replacing any of the wrong class, and removeforbidden ones.</import-step></import-steps> - Create a new file toolset.xml (path CPSMessages/profiles/default)
<?xml version="1.0"?>
<tool-setup>
<required tool_id="portal_imessages"
class="Products.CPSMessages.MessagesTool.MessagesTool"/>
</tool-setup> - Restart Zope and import the profile CPS Messages from the ZMI in the tool portal_setup. The new tool portal_imessages should be available from the root of the CPS instance.
Did you enjoy this post? Leave a comment please, even if you didn't enjoyed! Thanks ;-)
1 comment:
Good job man !!! I encourage you to continue working on this tips.
Post a Comment