[Zope-CMF] how to create an indexed attribute programmatically?

Shane Landrum srl at boston.com
Thu Jan 22 12:01:28 EST 2004


On Thu, Jan 22, 2004 at 11:14:15AM -0500, Gerry Kirk wrote:
> Hi,
> 
> In reading the source in PluggableIndexes/common/Unindex.py, and 
> CMFCore/CatalogTool.py, I should be able to create an indexed attribute 
> by the following:
> 
> catalog.addIndex('indexname','indextype','attribute_name')
> 
> It creates the index, but the attribute is not indexed. I want to index 
> Title so I can sort on it:
> 
> catalog.addIndex('Title_sort','FieldIndex','Title')
> 
> I can do this through the ZMI, so I'm not sure what is different here.

Looking at CMFCore/CatalogTool.py's _initIndexes method,
it looks like you also need to run addColumn. I'm not sure
what this does under the hood, but it seems like this may
be your problem.

I have a related problem: I'm trying to add a new index
to a CMF-based catalog that indexes a bunch of objects--- around
several hundred thousand at least. I've got code that does
this, and it runs fine on a development system with many
fewer assets. When I deploy it on production, the reindexing
takes forever--- it actually never completes. Where should
I be looking to figure out how to solve this problem?

srl
-- 
Shane Landrum, Software Engineer    srl at boston.com
boston.com / NY Times Digital



More information about the Zope-CMF mailing list