############################################################################## # # Copyright (c) 2003 Epoz Contributors. See CREDITS.txt # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Install epoz in CMF and, if available, Plone This is best executed using CMFQuickInstaller $Id: Install.py 2843 2004-01-20 11:21:53Z guido $ """ import os.path from StringIO import StringIO from App.Common import package_home from Products.CMFCore.utils import getToolByName, minimalpath from Products.CMFCore.DirectoryView import createDirectoryView from Products.epoz import epoz_globals epoz_package_dir = package_home(epoz_globals) def register_layer(self, relpath, name, out): """Register a file system directory as skin layer """ skinstool = getToolByName(self, 'portal_skins') if name not in skinstool.objectIds(): epoz_plone_skin_dir = os.path.join(epoz_package_dir, relpath) createDirectoryView(skinstool, epoz_plone_skin_dir, name) print >>out, "The layer '%s' was added to the skins tool" % name # put this layer into all known skins for skinName in skinstool.getSkinSelections(): path = skinstool.getSkinPath(skinName) path = [i.strip() for i in path.split(',')] try: if name not in path: path.insert(path.index('custom')+1, name) except ValueError: if name not in path: path.append(name) path = ','.join(path) skinstool.addSkinSelection(skinName, path) def install_plone(self, out): """Install with plone """ # register the plone skin layer register_layer(self, 'plone', 'epoz_plone', out) # register as editor portal_props = getToolByName(self, 'portal_properties') site_props = getattr(portal_props,'site_properties', None) attrname = 'available_editors' if site_props is not None: editors = list(site_props.getProperty(attrname)) if 'Epoz' not in editors: editors.append('Epoz') site_props._updateProperty(attrname, editors) print >>out, "Added 'Epoz' to available editors in Plone." def install(self): out = StringIO() # register the core layer register_layer(self, 'common', 'epoz', out) # try for plone try: import Products.CMFPlone install_plone(self, out) except ImportError: pass print >>out, "epoz successfully installed" return out.getvalue()