[CMF-checkins] CVS: Products/CMFCalendar/Extensions - Install.py:1.2.4.1

jshell@cvs.baymountain.com jshell@cvs.baymountain.com
Tue, 24 Jul 2001 14:04:50 -0400


Update of /cvs-repository/Products/CMFCalendar/Extensions
In directory cvs.zope.org:/tmp/cvs-serv19748

Modified Files:
      Tag: CMF-1_1-branch
	Install.py 
Log Message:
Merging in changes from the HEAD that deal with catalog index/column
API differences between Zope 2.3 and Zope 2.4.

 
=== Products/CMFCalendar/Extensions/Install.py 1.2 => 1.2.4.1 ===

 from Products.CMFCore.utils import getToolByName
 from Products.CMFCalendar import Event, event_globals
+from Acquisition import aq_base
 from cStringIO import StringIO
 import string
-from Acquisition import aq_base
 
 def install(self):
     " Register the CMF Event with portal_types and friends "
+    out = StringIO()
+    typestool = getToolByName(self, 'portal_types')
+    skinstool = getToolByName(self, 'portal_skins')
+    metadatatool = getToolByName(self, 'portal_metadata')
     catalog = getToolByName(self, 'portal_catalog')
+
+    # 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
@@ -122,14 +130,12 @@
     else:
         # Zope 2.3 and below
         addColumn = catalog._catalog.addColumn
-    out = StringIO()
     addIndex('start', 'FieldIndex')
     addIndex('end', 'FieldIndex')
     addColumn('start')
     addColumn('end')
-    typestool = getToolByName(self, 'portal_types')
-    skinstool = getToolByName(self, 'portal_skins')
-    metadatatool = getToolByName(self, 'portal_metadata')
+    out.write('Added "start" and "end" field indexes and columns to '\
+              'the portal_catalog\n')
 
     # Borrowed from CMFDefault.Portal.PortalGenerator.setupTypes()
     # We loop through anything defined in the factory type information
@@ -143,18 +149,19 @@
             out.write('Object "%s" already existed in the types tool\n' % (
                 t['id']))
 
-    # Setup an MetadataTool Element Policy for Events
-    
-    metadatatool.addElementPolicy(element='Subject'
-        ,content_type='Event'
-        ,is_required=0
-        ,supply_default=0
-        ,default_value=''
-        ,enforce_vocabulary=0
-        ,allowed_vocabulary=('Appointment', 'Convention', 'Meeting', 'Social Event', 'Work')
-        ,REQUEST=None
+    # Setup a MetadataTool Element Policy for Events
+    metadatatool.addElementPolicy(
+        element='Subject',
+        content_type='Event',
+        is_required=0,
+        supply_default=0,
+        default_value='',
+        enforce_vocabulary=0,
+        allowed_vocabulary=('Appointment', 'Convention', 'Meeting',
+                            'Social Event', 'Work'),
+        REQUEST=None,
         )
-    out.write('Event added to Metdata element Policies')
+    out.write('Event added to Metdata element Policies\n')