[Zapp-cvs-commit] ZApp/Extensions Install.py,NONE,1.1
Brought to you by:
sspickle
|
From: <ssp...@us...> - 2003-06-25 11:45:56
|
Update of /cvsroot/zapp/ZApp/Extensions
In directory sc8-pr-cvs1:/tmp/cvs-serv14999/Extensions
Added Files:
Install.py
Log Message:
added some skins to ZApp CMF core..
--- NEW FILE: Install.py ---
"""
Installer for CMF Survey..
"""
__version__='$Revision: 1.1 $'[11:-2]
from Products.CMFCore.TypesTool import ContentFactoryMetadata
from Products.CMFCore.DirectoryView import addDirectoryViews
from Products.CMFCore.utils import getToolByName
from Products.ZApp import ZApp_CMFBase, zapp_globals
from ZODB.PersistentMapping import PersistentMapping
from cStringIO import StringIO
import string
def install(self):
" Register ZApp_CMF_Base with portal_types and friends "
out = StringIO()
typestool = getToolByName(self, 'portal_types')
skinstool = getToolByName(self, 'portal_skins')
workflowtool = getToolByName(self, 'portal_workflow')
# Borrowed from CMFDefault.Portal.PortalGenerator.setupTypes()
# We loop through anything defined in the factory type information
# and configure it in the types tool if it doesn't already exist
for t in ZApp_CMFBase.factory_type_information:
if t['id'] not in typestool.objectIds():
cfm = apply(ContentFactoryMetadata, (), t)
typestool._setObject(t['id'], cfm)
out.write('Registered %s with the types tool\n' % t['id'])
else:
out.write('Object "%s" already existed in the types tool\n' % (
t['id']))
# Setup the skins
if 'zapp_generic' not in skinstool.objectIds():
# We need to add Filesystem Directory Views for any directories
# in our skins/ directory. These directories should already be
# configured.
addDirectoryViews(skinstool, 'skins', zapp_globals)
out.write("Added 'hec' directory view to portal_skins\n")
# ---------------------
# Now we need to go through the skin configurations and insert
# 'zbsm' into the configurations. Preferably, this should be
# right before where 'content' is placed. Otherwise, we append
# it to the end.
skins = skinstool.getSkinSelections()
for skin in skins:
path = skinstool.getSkinPath(skin)
path = map(string.strip, string.split(path,','))
for dir in ('zapp_generic','zapp_xml',):
if not dir in path:
try:
idx = path.index( 'custom' )
except ValueError:
idx = 999
path.insert( idx+1, dir )
out.write("Added '%s' to %s skin\n" % (dir,skin))
path = string.join(path, ', ')
# addSkinSelection will replace existing skins as well.
out.write("for skin %s setting path.. %s\n" % (skin, path))
skinstool.addSkinSelection(skin, path)
out.seek(0)
result = out.read()
return "OK!\n\n" + result
|