[Zope-CMF] replacing CMF tools?

Karl Anderson kra@monkey.org
28 Jun 2002 11:07:34 -0700


Tres Seaver <tseaver@zope.com> writes:

> > I'd like to do this to an existing CMF site, if possible, for quicker
> > testing.
> 
> Basically, you just delete it in the ZMI and add a new instance of
> your tool under its name.  As long as you implement the tool's
> interface, everything should just work.  You can add an instance of
> the stock tool by selecting "CMF Default Tool" from the add list,
> and then selecting "Memberdata tool" from the factory form.

What about the CMFy initialization that the core tools currently do?
Perhaps this isn't necessary because I'm subclassing those tools - I
just looked at Plone's __init__ and it was just doing the ToolInit.

Here's what's working for me now.



import MyMemberDataTool, MyMembershipTool
from Products.CMFCore import utils

#ProductHelp_icon=ImageFile('HelpSys/images/productHelp.gif')

import sys
this_module = sys.modules[ __name__ ]

tools = (MyMemberDataTool.MyMemberDataTool,
         MyMembershipTool.MyMembershipTool)

z_tool_bases = utils.initializeBasesPhase1(tools, this_module)

def initialize(context):
    utils.initializeBasesPhase2(z_tool_bases, context)

    utils.ToolInit( 'CMF Core Tool CS'
                    , tools=tools
                    , product_name='CMFCoreCS'
                    , icon='toolCS.gif' #XXX eh?
                    ).initialize( context )

    for tool in tools:
        # XXX we don't have an icon registered, replace the broken one
        # that was installed with the CMF one
        # it would be helpful to show that we're different in the ZMI
        #tool.icon = 'misc_/%s/%s' % (self.product_name, self.icon)
        tool.icon = 'misc_/%s/%s' % ('CMFCore', 'tool.gif')


-- 
Karl Anderson      kra@monkey.org           http://www.monkey.org/~kra/