[gen] Cleaner and more robust approach when using Zope database indexes.

This commit is contained in:
Gaetan Delannay 2012-09-04 18:00:22 +02:00
parent 5c2d94236f
commit c2eaab4b44
6 changed files with 75 additions and 30 deletions

View file

@ -163,10 +163,10 @@ class ZopeInstaller:
catalog.addIndex(indexName, indexType)
else:
catalog.addIndex(indexName, indexType,extra=ZCTextIndexInfo)
# Indexing database content based on this index.
catalog.reindexIndex(indexName, self.app.REQUEST)
logger.info('Created index "%s" of type "%s"...' % \
(indexName, indexType))
# Indexing database content based on this index.
lexiconInfos = [
appy.Object(group='Case Normalizer', name='Case Normalizer'),
@ -188,19 +188,11 @@ class ZopeInstaller:
elements=self.lexiconInfos)
# Create or update Appy-wide indexes and field-related indexes
indexInfo = {'State': 'FieldIndex', 'UID': 'FieldIndex',
'Title': 'ZCTextIndex', 'SortableTitle': 'FieldIndex',
'SearchableText': 'ZCTextIndex', 'Creator': 'FieldIndex',
'Created': 'DateIndex', 'ClassName': 'FieldIndex',
'Allowed': 'KeywordIndex'}
indexInfo = gen.defaultIndexes.copy()
tool = self.app.config
for className in self.config.attributes.iterkeys():
wrapperClass = tool.getAppyClass(className, wrapper=True)
for appyType in wrapperClass.__fields__:
if not appyType.indexed or (appyType.name == 'title'): continue
n = appyType.name
indexName = 'get%s%s' % (n[0].upper(), n[1:])
indexInfo[indexName] = appyType.getIndexType()
indexInfo.update(wrapperClass.getIndexes(includeDefaults=False))
self.installIndexes(indexInfo)
def getAddPermission(self, className):
@ -345,7 +337,6 @@ class ZopeInstaller:
appyTool.log('Translation "%s" updated from "%s".' % \
(translation.id, poName))
def configureSessions(self):
'''Configure the session machinery.'''
# Register a function warning us when a session object is deleted. When