SearchableText was broken.
This commit is contained in:
parent
52816ec343
commit
e62e00d367
8 changed files with 58 additions and 13 deletions
|
@ -361,7 +361,8 @@ class ClassDescriptor(appy.gen.descriptors.ClassDescriptor):
|
|||
m += '\n' + ' '*spaces + 'def get%s%s(self):\n' % (n[0].upper(), n[1:])
|
||||
spaces += TABS
|
||||
m += ' '*spaces + "'''Gets indexable value of field \"%s\".'''\n" % n
|
||||
m += ' '*spaces + 'return self.getAppyType("%s").getValue(self)\n' % n
|
||||
m += ' '*spaces + 'return self.getAppyType("%s").getIndexValue(' \
|
||||
'self)\n' % n
|
||||
self.methods = m
|
||||
|
||||
class ToolClassDescriptor(ClassDescriptor):
|
||||
|
|
|
@ -667,14 +667,14 @@ class Generator(AbstractGenerator):
|
|||
if classDescr.isFolder():
|
||||
baseClass = 'OrderedBaseFolder'
|
||||
baseSchema = 'OrderedBaseFolderSchema'
|
||||
parents = [baseClass, 'BaseMixin']
|
||||
parents = ['BaseMixin', baseClass]
|
||||
imports = []
|
||||
implements = [baseClass]
|
||||
for baseClass in classDescr.klass.__bases__:
|
||||
if self.determineAppyType(baseClass) == 'class':
|
||||
bcName = getClassName(baseClass)
|
||||
parents.remove('BaseMixin')
|
||||
parents.append(bcName)
|
||||
parents.insert(0, bcName)
|
||||
implements.append(bcName)
|
||||
imports.append('from %s import %s' % (bcName, bcName))
|
||||
baseSchema = '%s.schema' % bcName
|
||||
|
|
|
@ -56,9 +56,17 @@ class PloneInstaller:
|
|||
{s_indexName:s_indexType}. Here are some examples of index types:
|
||||
"FieldIndex", "ZCTextIndex", "DateIndex".'''
|
||||
catalog = ploneSite.portal_catalog
|
||||
indexNames = catalog.indexes()
|
||||
zopeCatalog = catalog._catalog
|
||||
for indexName, indexType in indexInfo.iteritems():
|
||||
if indexName not in indexNames:
|
||||
# If this index already exists but with a different type, remove it.
|
||||
if (indexName in zopeCatalog.indexes):
|
||||
oldType = zopeCatalog.indexes[indexName].__class__.__name__
|
||||
if oldType != indexType:
|
||||
catalog.delIndex(indexName)
|
||||
logger.info('Existing index "%s" of type "%s" was removed:'\
|
||||
' we need to recreate it with type "%s".' % \
|
||||
(indexName, oldType, indexType))
|
||||
if indexName not in zopeCatalog.indexes:
|
||||
# We need to create this index
|
||||
if indexType != 'ZCTextIndex':
|
||||
catalog.addIndex(indexName, indexType)
|
||||
|
@ -68,8 +76,6 @@ class PloneInstaller:
|
|||
catalog.reindexIndex(indexName, ploneSite.REQUEST)
|
||||
logger.info('Created index "%s" of type "%s"...' % \
|
||||
(indexName, indexType))
|
||||
# TODO: if the index already exists but has not the same type, we
|
||||
# re-create it with the same type and we reindex it.
|
||||
|
||||
actionsToHide = {
|
||||
'portal_actions': ('sitemap', 'accessibility', 'change_state','sendto'),
|
||||
|
|
|
@ -793,7 +793,7 @@ class BaseMixin:
|
|||
transition on an object.'''
|
||||
rq = self.REQUEST
|
||||
self.portal_workflow.doActionFor(self, rq['workflow_action'],
|
||||
comment = rq.get('comment', ''))
|
||||
comment = rq.get('comment', ''))
|
||||
self.reindexObject()
|
||||
# Where to redirect the user back ?
|
||||
# TODO (?): remove the "phase" param for redirecting the user to the
|
||||
|
@ -1040,4 +1040,13 @@ class BaseMixin:
|
|||
response.setHeader('Cachecontrol', 'no-cache')
|
||||
response.setHeader('Expires', 'Thu, 11 Dec 1975 12:05:05 GMT')
|
||||
return theFile.index_html(self.REQUEST, self.REQUEST.RESPONSE)
|
||||
|
||||
def SearchableText(self):
|
||||
'''This method concatenates the content of every field with
|
||||
searchable=True for indexing purposes.'''
|
||||
res = []
|
||||
for field in self.getAllAppyTypes():
|
||||
if not field.searchable: continue
|
||||
res.append(field.getIndexValue(self, forSearch=True))
|
||||
return res
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -11,7 +11,7 @@ schema = Schema((<!fields!>
|
|||
),)
|
||||
fullSchema = OrderedBaseFolderSchema.copy() + schema.copy()
|
||||
|
||||
class <!toolName!>(UniqueObject, OrderedBaseFolder, ToolMixin):
|
||||
class <!toolName!>(ToolMixin, UniqueObject, OrderedBaseFolder):
|
||||
'''Tool for <!applicationName!>.'''
|
||||
security = ClassSecurityInfo()
|
||||
__implements__ = (getattr(UniqueObject,'__implements__',()),) + (getattr(OrderedBaseFolder,'__implements__',()),)
|
||||
|
|
|
@ -9,7 +9,7 @@ schema = Schema((<!fields!>
|
|||
),)
|
||||
fullSchema = BaseSchema.copy() + schema.copy()
|
||||
|
||||
class <!applicationName!>User(BaseContent, BaseMixin):
|
||||
class <!applicationName!>User(BaseMixin, BaseContent):
|
||||
'''User mixin.'''
|
||||
security = ClassSecurityInfo()
|
||||
__implements__ = (getattr(BaseContent,'__implements__',()),)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue