from Products.Archetypes.public import listTypes from Products.Archetypes.Extensions.utils import installTypes, install_subskin from Products.Archetypes import types_globals from Products.ATGuestbook.config import * from Products.CMFCore.utils import getToolByName from StringIO import StringIO def install(self): out = StringIO() installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) install_subskin(self, out, GLOBALS) setFolderProperties(self, out) setWorkflows(self, out) setPortalFactoryTypes(self, out, GLOBALS) print >> out, "Successfully installed %s." % PROJECTNAME return out.getvalue() def setFolderProperties(self, out, globals=types_globals): props = self.portal_properties.site_properties tabs = getattr(props, 'use_folder_tabs') newtabs = list(tabs) contents = getattr(props, 'use_folder_contents') newcontents = list(contents) for type_name in folderish_types: if type_name not in newtabs: newcontents.append(type_name) if type_name not in newcontents: newcontents.append(type_name) props._updateProperty('use_folder_tabs', newtabs) props._updateProperty('use_folder_contents', newcontents) print >>out, "site_properties: added folderish types." def setWorkflows(self, out, globals=types_globals): wf_tool = getToolByName(self, 'portal_workflow') wf_tool.setChainForPortalTypes(folderish_types, 'folder_workflow') print >>out, "workflow: set folder_workflow for folderish types." def setPortalFactoryTypes(self, out, globals=types_globals): portal_factory = getToolByName(self, 'portal_factory') portal_factory.manage_setPortalFactoryTypes(listOfTypeIds=portal_factory_types) print >>out, "portal_factory: added '%s'." % "', '".join(portal_factory_types)