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,)
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
Replies to this comment