[Zope-CMF] CMF Tool gotchas

Paul Winkler pw_lists at slinkp.com
Wed Nov 19 15:45:31 EST 2003


I'm now working on my second CMF Tool, which I find to be a nice way to
add features to CMF. Things are working well.
But there are a couple of annoyances...

1) I can't for the life of me figure out how to register my own icon for the tool.
In my __init__.py I have this:

def initialize(context):
    """Initialize the product."""
    utils.ToolInit(FooTool.FooTool.meta_type
                   , tools=(FooTool.FooTool,)
                   , product_name='FooTool' 
                   , icon='www/footool.gif', # why doesn't this work?
    ).initialize( context )

www/footool.gif exists in my sources.
In the html source, I can see that the icon URL is:
http://localhost:8080/misc_/FooTool/www/footool.gif
... which does not seem to exist.
What else do I need to do?

2) Adding the Filesystem Directory Views with an Install.py external
method was frustrating. The (canonical?) example for CMFCalendar confused me:

    if '' not in skinstool.objectIds():
        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews(skinstool, 'skins', event_globals)
        out.write("Added '' directory view to portal_skins\n")

I don't know why it took me so long to figure out, but this assumes that
the skins/ directory itself is NOT used for a FilesystemDirectoryView...
only its subdirecories are. It is possible to have a skins/ directory
that you register (even using a different name for the FSDV), but
it's a bit more work:


    from App.Common import package_home
    from Products.CMFCore.utils import minimalpath
    from Products.CMFCore.DirectoryView import createDirectoryView

    if 'foo' not in skinstool.objectIds():
        # Add the top-level Filesystem Directory View.
        mp = minimalpath("%s/skins" % package_home(custmanagement_globals))
        createDirectoryView(skinstool, mp, 'foo')
        out.write("Added %s directory view to portal_skins\n" % mp)

        # We need to add Filesystem Directory Views for any directories
        # in our skins/ directory.  These directories should already be
        # configured.
        addDirectoryViews(skinstool, 'skins', event_globals)
        out.write("Added '' directory view to portal_skins\n")

After figuring that out I decided it was icky, and just added a subdirectory
for my skins stuff.


-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's ULTRA FRAGILE WATER HIPPO!
(random hero from isometric.spaceninja.com)



More information about the Zope-CMF mailing list