# Copyright 2005 by Vahur Rebas """ School Portal customization policy for Plone Sites """ __author__ = 'Vahur Rebas' from zLOG import INFO, ERROR from Products.CMFSchool.config import GLOBALS, ROLES, SKINLIST from Products.Archetypes.Extensions.utils import install_subskin from Products.CMFCore.utils import getToolByName from Products.CMFCore.DirectoryView import registerDirectory, addDirectoryViews def setPortalProperties(self, portal): """ Sets properties of the portal, such as title. """ portal.manage_changeProperties(title="Welcome to School Portal") portal.portal_groupdata.manage_addProperty('klass',0,'boolean') def setSiteProperties(self, portal): """ Modifies and/or adds properties in portal_properties """ pass def installPortalTools(self, portal): """Add any necessary portal tools""" out = [] install_subskin(portal, out, GLOBALS) def installPortalSkins(self, portal): """ Installs skins """ sk_tool = portal.portal_skins registerDirectory('styles', GLOBALS) addDirectoryViews( sk_tool, 'styles', GLOBALS) for skin in SKINLIST: path = [elem.strip() for elem in \ sk_tool.getSkinPath('Plone Default').split(',')] path.insert(path.index('custom')+1, skin) sk_tool.addSkinSelection(skin, ','.join(path)) #for skin in sk_tool.getSkinSelections(): # path.insert(path.index('my_custom')+1, skin) # getattr(sk_tool, skin).append('myc') def installPortalRoles(self, portal): """ adds roles. creates groups """ out = [] for x in ROLES: portal._addRole(x) def installProducts(self, portal): """ install any additional products """ prods = ['CMFTimeTable','CMFSchool','CMFCurriculum','CMFProgressInterview'] qi = getToolByName(portal, 'portal_quickinstaller', None) for x in prods: qi.installProduct(x) functions = { 'installPortalSkins': installPortalSkins, 'setPortalProperties': setPortalProperties, 'setSiteProperties': setSiteProperties, 'installPortalTools': installPortalTools, 'installProducts': installProducts, 'installPortalRoles': installPortalRoles, } class SchoolSiteSetup: type = 'School Portal Setup' description = "School Portal Policy." functions = functions single = 0 # huh!? def __init__(self, portal): self.portal = portal def setup(self): pass def delItems(self, fns): out = [] out.append(('no way to remove function', INFO)) return out def addItems(self, fns): out = [] for fn in fns: self.functions[fn](self, self.portal) out.append(('Function %s has been applied' % fn, INFO)) return out def active(self): return 1 def installed(self): return [] def available(self): """ functions """ return self.functions.keys()