[Zope] Programmatically adding and deleting indexes in a
ZCatalog
Martijn Pieters
mj@antraciet.nl
Tue, 19 Oct 1999 09:43:58 +0200
At 06:29 19/10/99 , Benno Rice wrote:
>Hi,
>
>I've got one of these ObjectManager/ZCatalog derived ZClasses, and I'm
>wanting to add some code to my _add method to delete some of the default
>indexes and add some new ones.
>
>How would I go about doing this?
Here is a real life example:
<dtml-with "EventFolder.createInObjectManager(REQUEST['id'], REQUEST)">
<SNIP>
<dtml-comment>Remove default Catalog schema</dtml-comment>
<dtml-call "manage_delColumns(['title', 'meta_type', 'summary'],
REQUEST, RESPONSE, URL1)">
<dtml-call "manage_delIndexes(['id', 'title', 'meta_type',
'PrincipiaSearchSource'], REQUEST, RESPONSE, URL1)">
<dtml-comment>Install new Catalog schema</dtml-comment>
<dtml-call "manage_addColumn('this', REQUEST, RESPONSE, URL1)">
<dtml-call "manage_addColumn('day', REQUEST, RESPONSE, URL1)">
<dtml-call "manage_addColumn('start', REQUEST, RESPONSE, URL1)">
<dtml-call "manage_addIndex('day', 'FieldIndex', REQUEST, RESPONSE, URL1)">
<dtml-call "manage_addIndex('start', 'FieldIndex', REQUEST, RESPONSE,
URL1)">
<dtml-call "manage_addIndex('end', 'FieldIndex', REQUEST, RESPONSE, URL1)">
<dtml-call "manage_addIndex('description', 'TextIndex', REQUEST,
RESPONSE, URL1)">
</dtml-with>
I am not yet sure wether or not the 'this' column is a good idea, but I now
can directly reference it using <dtml-with this> when iterating over
ZCatalog result sets. I have to wake up every object returned by such a
search anyway, but maybe this hack also wakes up every other cataloged
object. This is not a problem in my case, as I expect to see all objects in
this particular instance to be accessed very regularly, I am only using the
ZCatalog features to do easy sorting and sifting.
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------