Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Products » Open Source » Minimal Plone Tool
Downloads
You can download mxm products here.

Due to it's technical and international nature, this section is in english.

Max M Has a blog too.

og er glad for mad

 

Minimal Plone/Zope Tool

Sometimes you want to use an external method. Sometimes you want to use more than one. Some times you want to make a new content type that needs a tool for common operations or data. This is a minimal base class for making tools. It can also be used as the base for a minimal Zope product.

To make your own tool you should just do a search and replace on minimalPloneTool.

So if you want to make a tool called portal_mytool use your editors version of:

    Find What: "minimalPloneTool"
    Replace with: "portal_mytool"

You can also use the rename.py script to do it for you:

    > rename.py portal_mytool

Put the tool in your Products directory and install it from the zmi.

License:

Public Domain

Contact:

maxm@mxm.dk

Download:

Download from the download section here

The class looks like this:

    # Zope
    from OFS import SimpleItem
    from OFS.PropertyManager import PropertyManager
    from Products.PageTemplates.PageTemplateFile import PageTemplateFile
    from AccessControl import ClassSecurityInfo

    ## BEGIN Zope tool/product
    ## Uncomment this block to make it a plain Zope product/tool
    #class MinimalPloneTool(PropertyManager, SimpleItem.SimpleItem):
    ## END Zope tool/product

    # BEGIN Plone tool
    # Comment out this block if you want a plain Zope product/tool
    from Products.CMFCore.utils import UniqueObject
    from Products.CMFCore.ActionProviderBase import ActionProviderBase

    class MinimalPloneTool(UniqueObject, PropertyManager, 
                           SimpleItem.SimpleItem, ActionProviderBase):
    # END Plone tool

        "The MinimalPloneTool tool"

        meta_type = 'MinimalPloneTool'

        id = 'MinimalPloneTool'

        manage_options = PropertyManager.manage_options + \
                         SimpleItem.SimpleItem.manage_options + (
                {'label': 'View', 'action': 'index_html',},
        )

        _properties = (
            {'id':'title', 'type':'string', 'mode':'w'},
        )

        # Standard security settings
        security = ClassSecurityInfo()

        security.declareProtected('Manage properties', 'index_html')
        index_html = PageTemplateFile('zpt/index_html', globals())

    #####################################################
    # Constructor functions, only used when adding class
    # to objectManager

    def manage_addAction(self, REQUEST=None):
        "Add tool instance to parent ObjectManager"
        id = MinimalPloneTool.id
        self._setObject(id, MinimalPloneTool())
        if REQUEST is not None:
            return self.manage_main(self, REQUEST)

    constructors = (manage_addAction,)

Created by maxm
Last modified 2005-01-19 03:37 PM

typo

Posted by Anonymous User at 2005-03-03 10:55 AM
hi max,

in the block marked 'begin plone tool' there is a comment saying something about Zope tool ... that should presumably read Plone tool instead.

cheers

jeremy