Installation
The 'Extensions/Install.py' script is called by the 'portal_quickinstaller' tool (which is called from the 'Add/Remove Products' page in the Plone control panel) and is responsible for configuring the portal when a product is installed.
For RichDocument, Install.py registers the content types and skins and sets a number of portal properties to tell Plone how to treat RichDocument objects. Several of the specifics will be described in more details later, but the elements of the 'install()' method that will be common to most content types are::
def install(self):
"""Install RichDocument: Install content types, skin layer, install the
stylesheet, set up global properties, enable the portal factory and
set up form controller actions for the widget actions
"""
out = StringIO()
print >> out, "Installing RichDocument"
# Install types
classes = listTypes(PROJECTNAME)
installTypes(self, out,
classes,
PROJECTNAME)
print >> out, "Installed types"
# Install skin
install_subskin(self, out, product_globals)
print >> out, "Installed skin"
# Migrate FTI, to make sure we get the necessary infrastructure for the
# "display" menu to work.
migrated = migrateFTIs(self, product=PROJECTNAME)
print >>out, "Switched to DynamicViewFTI: %s" % ', '.join(migrated)
...
# Enable portal_factory
factory = getToolByName(self, 'portal_factory')
types = factory.getFactoryTypes().keys()
if 'RichDocument' not in types:
types.append('RichDocument')
factory.manage_setPortalFactoryTypes(listOfTypeIds = types)
print >> out, "Added RichDocument to portal_factory"
...
return out.getvalue()
Please refer to 'Install.py' for the rest of the source code, but briefly, this code:
o Installs the content types which have been registered with 'registerType()'. For RichDocument this is 'RichDocument' itself, as well as 'FileAttachment' and 'ImageAttachment'.
o Installs the skin filesystem directory views in 'portal_skins'. These are registered in the product's '__init__.py'. In 'RichDocument/__init__.py', we have::
# Register skin directories so they can be added to portal_skins
DirectoryView.registerDirectory('skins', product_globals)
DirectoryView.registerDirectory('skins/RichDocument', product_globals)
DirectoryView.registerDirectory('skins/attachment_widgets', product_globals )
o Migrates the type's Factory Type Information to use 'CMFDynamicViewFTI'. This extension of the standard FTI from CMF is necessary to support the "display" menu. See "dynamic views":dynamic-views for more details.
o Adds RichDocument to the list of types that use the portal factory. This ensures that if a user creates a new item but does not save it, it will not leave a stale object around. See "portal factory":portal-factory for more.
The rest of the installation script is concerned with setting various options by adding 'RichDocument' and its types to various properties in 'portal_properties'. See 'Install.py' and the following sections for details.
