Back to index

plone3  3.1.7
Install.py
Go to the documentation of this file.
00001 from Products.CMFCore.utils import getToolByName
00002 from cStringIO import StringIO
00003 from wicked.at import config
00004 from wicked.at.config import REFERENCE_MANAGER
00005 
00006 def configureWysiwyg(portal, out):
00007     props = getToolByName(portal, 'portal_properties')
00008     if not hasattr(props, 'site_properties'): # not plone
00009         return
00010     
00011     editors = props.site_properties.getProperty('available_editors')
00012     if "Kupu" in editors:
00013         # move it up in the list
00014         editors = list(editors)
00015         editors.remove('Kupu')
00016         editors = ['Kupu',] + editors
00017         props.site_properties._updateProperty('available_editors', editors)
00018 
00019 
00020 def configureReferenceCatalog(portal, out):
00021     catalog = getToolByName(portal, REFERENCE_MANAGER)
00022     for indexName, indexType in (
00023         ('targetId', 'FieldIndex'),
00024         ('targetTitle', 'FieldIndex'),
00025         ('targetURL', 'FieldIndex'), ):
00026 
00027         try:
00028             catalog.addIndex(indexName, indexType, extra=None)
00029         except:
00030             pass
00031         try:
00032             catalog.addColumn(indexName)
00033         except:
00034             pass
00035 
00036         catalog.manage_reindexIndex(indexName)
00037 
00038 
00039 def install(self):
00040     out = StringIO()
00041     configureReferenceCatalog(self, out)
00042     configureWysiwyg(self, out)
00043     reindex = None
00044     pc = getToolByName(self, 'portal_catalog')
00045     if not 'UID' in pc.schema():
00046         pc.addColumn('UID')
00047         reindex = True
00048         
00049     if not 'UID' in pc.indexes():
00050         pc.addIndex('UID', 'FieldIndex')
00051         reindex = True
00052         
00053     pc.manage_reindexIndex('UID')
00054     print >> out, "Successfully installed %s." % config.PROJECTNAME
00055     return out.getvalue()