[CMF-checkins] CVS: CMF/CMFCalendar/Extensions - Install.py:1.9
Yvo Schubbe
schubbe at web.de
Sun Jan 11 07:47:40 EST 2004
Update of /cvs-repository/CMF/CMFCalendar/Extensions
In directory cvs.zope.org:/tmp/cvs-serv9887/CMFCalendar/Extensions
Modified Files:
Install.py
Log Message:
cleanup:
- Zope 2.3 backwards compatibility
- apply
- string
- whitespace
- long lines
=== CMF/CMFCalendar/Extensions/Install.py 1.8 => 1.9 ===
--- CMF/CMFCalendar/Extensions/Install.py:1.8 Fri May 10 11:45:47 2002
+++ CMF/CMFCalendar/Extensions/Install.py Sun Jan 11 07:47:09 2004
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# 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
-#
+#
##############################################################################
"""\
This file is an installation script for CMFCalendar (Events). It's meant to be
@@ -24,15 +24,15 @@
Then go to the management screen for the newly added external method
and click the 'Try it' tab. The install function will execute and give
information about the steps it took to register and install the
-CMF Events into the CMF Site instance.
+CMF Events into the CMF Site instance.
"""
+
+from cStringIO import StringIO
+
from Products.CMFCore.TypesTool import ContentFactoryMetadata
from Products.CMFCore.DirectoryView import addDirectoryViews
from Products.CMFCore.utils import getToolByName, ToolInit
from Products.CMFCalendar import Event, event_globals
-from Acquisition import aq_base
-from cStringIO import StringIO
-import string
def install(self):
@@ -41,37 +41,25 @@
typestool = getToolByName(self, 'portal_types')
skinstool = getToolByName(self, 'portal_skins')
metadatatool = getToolByName(self, 'portal_metadata')
- catalog = getToolByName(self, 'portal_catalog')
+ ctool = getToolByName(self, 'portal_catalog')
portal_url = getToolByName(self, 'portal_url')
- # Due to differences in the API's for adding indexes between
- # Zope 2.3 and 2.4, we have to catch them here before we can add
- # our new ones.
- base = aq_base(catalog)
- if hasattr(base, 'addIndex'):
- # Zope 2.4
- addIndex = catalog.addIndex
- else:
- # Zope 2.3 and below
- addIndex = catalog._catalog.addIndex
- if hasattr(base, 'addColumn'):
- # Zope 2.4
- addColumn = catalog.addColumn
- else:
- # Zope 2.3 and below
- addColumn = catalog._catalog.addColumn
try:
- addIndex('start', 'FieldIndex')
- except: pass
+ ctool.addIndex('start', 'FieldIndex')
+ except: # XXX: bare except!
+ pass
try:
- addIndex('end', 'FieldIndex')
- except: pass
+ ctool.addIndex('end', 'FieldIndex')
+ except: # XXX: bare except!
+ pass
try:
- addColumn('start')
- except: pass
+ ctool.addColumn('start')
+ except: # XXX: bare except!
+ pass
try:
- addColumn('end')
- except: pass
+ ctool.addColumn('end')
+ except: # XXX: bare except!
+ pass
out.write('Added "start" and "end" field indexes and columns to '\
'the portal_catalog\n')
@@ -80,7 +68,7 @@
# and configure it in the types tool if it doesn't already exist
for t in Event.factory_type_information:
if t['id'] not in typestool.objectIds():
- cfm = apply(ContentFactoryMetadata, (), t)
+ cfm = ContentFactoryMetadata(**t)
typestool._setObject(t['id'], cfm)
out.write('Registered with the types tool\n')
else:
@@ -102,11 +90,11 @@
)
except: pass
out.write('Event added to Metadata element Policies\n')
-
+
# Add the CMFCalendar tool to the site's root
p = portal_url.getPortalObject()
x = p.manage_addProduct['CMFCalendar'].manage_addTool(type="CMF Calendar Tool")
-
+
# Setup the skins
# This is borrowed from CMFDefault/scripts/addImagesToSkinPaths.pys
if 'calendar' not in skinstool.objectIds():
@@ -123,17 +111,17 @@
skins = skinstool.getSkinSelections()
for skin in skins:
path = skinstool.getSkinPath(skin)
- path = map(string.strip, string.split(path,','))
+ path = [ id.strip() for id in path.split(',') ]
if 'calendar' not in path:
try: path.insert(path.index('content'), 'calendar')
except ValueError:
path.append('calendar')
-
+
try: path.insert(path.index('zpt_content'), 'zpt_calendar')
except ValueError:
pass
-
- path = string.join(path, ', ')
+
+ path = ', '.join(path)
# addSkinSelection will replace exissting skins as well.
skinstool.addSkinSelection(skin, path)
out.write("Added 'calendar' to %s skin\n" % skin)
@@ -142,4 +130,3 @@
skin))
return out.getvalue()
-
More information about the CMF-checkins
mailing list