portal_catalog: Archetypes versus GenericSetup

Martin Aspeli optilude at gmx.net
Tue Apr 17 23:29:22 UTC 2007


Dorneles Treméa wrote:
> Hey Maurits,
> 
>> Archetypes
>> ----------
>>
>> With archetypes you can add an index for a field in your schema, e.g.:
>>
>>      index="FieldIndex"
>>
>> Or you can add that field to the index *and* to the metadata:
>>
>>      index="FieldIndex:brains"
>>
>> I do not think it is possible to add a field *only* to the metadata
>> with Archetypes, so not in the Index as well.  Am I correct here?
> 
> IIRC, you can use something like:
> 
>      index=":brains"
> 
>> GenericSetup
>> ------------
>>
>> With GenericSetup you can add an index in profiles/default/catalog.xml:
>>
>>  <index name="getHours" meta_type="FieldIndex">
>>   <indexed_attr value="getHours"/>
>>
>> and you can add a column to the metadata:
>>
>>  <column value="getHours"/>
>>
>>
>> Of course when you are aiming for compatibility with Plone 2.1 you
>> should just use the Archetypes way.
>>
>> But for Plone 2.5 or 3.0, I wonder if it is better to rely on
>> GenericSetup only.
>>
>> What do you think?
> 
> /me will continue to use the AT approach when possible (e.g. when
> an AT schema is available) and the GS approach when it's not...

You can't do that (sensible/easily) if you use GS-based configuration of 
FTIs. the 'index' thing is used when you call installTypes() in an 
Install.py. With GS, there is no code calling installTypes() (and you 
probably don't want it to) so there is nothing processing the schema for 
indexes.

I find the GS approach much more natural and sensible anyway. Indexes 
are inhrently global things, in that if you add an index it will try to 
find a value every single object that's being cataloged. Tying it to an 
AT schema makes it look like it's only for that particular field on that 
particular object, which is wrong. It also mixes "runtime" code (the 
schema) and install-support code.

Martin





More information about the Product-Developers mailing list