InstallUtils
Category: Toolbox like products
—
Other products by this author
InstallUtils is a small Plone product consisting frequently used methods for the Install.py script. Unzip the product in the Products folder. View the README for the available methods and examples on how to use them.
Experimental releases
Upcoming and alpha/beta/candidate releases
- Alpha releases should only be used for testing and development.
- Beta releases and Release Candidates are normally released for production testing, but should not be used on mission-critical sites.
- Always install on a separate test server first, and make sure you have proper backups before installing.
Project Description
- Project resources
--------
1.0 Introduction
2.0 Available methods
1.0 Introduction
----------------
This is a tiny Plone product that provides some often used methods for an
Install.py script. You just have to unpack the product in your Plone
Products folder, that's all.
InstallUtils provides installation methods to be used in the Install.py script
for Plone products. The bundle takes the complexity out of your Install script,
into separately tested installer methods. This greatly enhances the stability
of your Install procedures. The bundle provides numerous methods often
used in an installation procedure, like installing external methods, new portal
roles, workflows, properties, etc.
All methods are coded in separate files, and are imported from the utils.py
file.
If you wish to add your own methods, please be so kind as to obey the following
rules, then send us the method:
* add python doc;
* add code comments;
* add print statements when starting your method, and when ending
your install, and in between whatever you're installing;
* have a beer.
2.0 Available methods
---------------------
All install methods use the portal variable, which is 'self' in the
Install.py script. The out variable is used to display messages to the output
of a call from the quickinstaller.
Use installer methods like so:
--------File: Install.py--------
from Products.InstallUtils.utils import *
from StringIO import StringIO
...
out = StringIO()
installFactory(self, out, ['FooThing', 'BarThing',])
...
--------------------------------
Examples are all assuming usage within Install.py.
2.1 installActionIcons(portal, out, icons=[])
---------------------------------------------
Install Action icons. icons should be a list of tuples, each tuple
like: (<category>, <id>, <icon url>, <title>)
Example:
installActionIcons(self, out,
[('plone', 'upload_csv', 'upload_icon.gif', 'Upload'),])
2.2 installActions(portal, out, actions, provider='portal_actions')
-------------------------------------------------------------------
Install new actions to the portal. using the provider specified, or
portal_actions per default. Each action in the actions list should be
a tuple like: (name, action, condition, permission, category)
2.3 hideActions(self, out, provider, actionIds=[], category=None)
-----------------------------------------------------------------
Hide actions with given id's.
2.4 installConfiglets(self, out, configlets)
--------------------------------------------
Install a configlet for the plone site. configlets parameter should be
a list of hashes, each providing at least values for 'id', 'appId',
'name', 'action', 'condition', 'permission', 'category' and
'imageUrl'.
Example:
CONFIGLET = {
'id': 'profile_member_prefs',
'appId': 'PloneProfiles',
'name': 'Member Profile',
'action': 'python:portal.doSomething',
'condition': 'python: member',
'permission': ('View',),
'category': 'Member',
'imageUrl': 'profile_icon.gif',
}
installConfiglet(self, out, CONFIGLET)
2.5 installExternalMethod(portal, out, module, method, project)
---------------------------------------------------------------
Install an external method.
Example:
installExternalMethod(self, out,
'createDynamicImageFromString',
'createDynamicImage',
'DynamicImager')
2.6 installFactory(portal, out, types=[])
-----------------------------------------
Install content types as factory types.
Example:
installFactory(self, out, ['FooThing', 'BarThing',])
2.7 installFrontPage(portal, out, title='', text='')
----------------------------------------------------
Install the frontpage title and text.
2.8 installLanguage(portal, out, default='en', languages=())
------------------------------------------------------------
Tell Plone to use the following languages, and default. This assumes
PloneLanguageTool is installed.
2.9 installPermissions(object, out, permissions=())
------------------------------------------------
Install new permissions onto object, usually your Plone instance.
Example:
PERMISSIONS = [
('PloneProfiles: Create Profile', 1, ['Member',]),
('PloneProfiles: List Profiles', 1, ['Member',]),
]
installPermissions(self, out, PERMISSIONS)
2.10 installPrerequisites(portal, out, prereqs=[], nofail=False)
----------------------------------------------------------------
Install the following prerequisites for your product, if available.
When nofail is set to False, installation will fail if any of the
prerequisites is not installable.
2.11 installMemberProperties(portal, out, props=())
---------------------------------------------------
Install member properties. This assumes the normal membership is used,
not CMFMember. props is a list of tuples, each tuple like (<id>,
<type>, <value>),
2.12 installPropertiesSheet(portal, out, properties, properties_id,
properties_title)
-------------------------------------------------------------------
Install a new properties sheet to the portal properties tool, with all
properties listed in the properties variable. This is a list of tuples,
each tuple like (<id>, <type>, <value>).
2.13 installPropertiesToObject(portal, out, obj, props=(), create=True)
-----------------------------------------------------------------------
Install properties to a properties container. 'props' is a list of
tuples, each tuple like (<id>, <type>, <value>),
2.14 installPythonScript(portal, out, root, scriptname, scriptbody,
force=False)
-------------------------------------------------------------------
Install a python script to the given root.
2.15 installRoles(portal, out, roles)
-------------------------------------
Install given roles to Plone root. Roles is a list of role id's.
Example:
installRoles(self, out, ['Teacher', 'Student'])
2.16 installSetAddableTypesForObject(portal, type, out, types=[])
-----------------------------------------------------------------
Set the addable types for a given type.
Example
installSetAddableTypesForObject(self, 'FooThing', out, ['BarThing'])
2.17 installUnsetFilterForObject(portal, type, out )
----------------------------------------------------
Unset the filter for a given object, Handy when installing content into
objects that normally during portal operation do not allow this.
2.18 installSkin(portal, out, globals, skin_id, pos=-1)
-------------------------------------------------------
Install the skin for your product, given the position in 'pos'. This
enables installing your skin at position '0', to override all other
skins.
2.19 installStructure(portal, out, struct=[], reset_attributes=False,
reset_permissions=True)
---------------------------------------------------------------------
Create the given structure in the portal. The structure should be
given in tuples, where each tuple contains the id for the object to
create, the type, a map of values to set (done with setters) on the
created object, a list of nested objects to create and a list of
permissions to set on the object.
If reset_attributes is set to true, given attributes will be set on
objects if they already exist. If reset_permissions is set to true,
permissions will be set on objects if they already exist.
Example:
STRUCT = [('map0',
'Folder',
{'title':'Map 0'},
[('submap0', 'Folder', {}, [])]),
('map1',
'Folder', {'title':'Map 1'},
[],
[('View', 0, ['Manager'])]),
]
installStructure(self, out, STRUCT)
2.20 installWorkflows(portal, out, wfs={}, updateRoleMappings=False)
--------------------------------------------------------------------
Install workflows. When updateRoleMappings is set to False, security
settings are not updated. This may be useful for very big sites.
Example:
WORKFLOW_MAP = {'participant_workflow': ('Participant Workflow',
('Participant',)),}
installWorkflows(self, out, WORKFLOW_MAP)
2.21 installHTTPCache(self, out, id, label, anonymous_only=1, interval=3600, notify_urls=())
--------------------------------------------------------------------
Create your own HTTPCache when you need specific settings for certain objects.
2.22 installRAMCache(self, out, id, label, threshold=1000, cleanup_interval=300, request_vars=('AUTHENTICATED_USER',), max_age=3600)
--------------------------------------------------------------------
Create your own RAMCache when you need specific settings for certain objects.