[Zope-CMF] get empty list from Contributors in search results

Tres Seaver tseaver@palladion.com
Wed, 22 Aug 2001 08:30:27 -0400


Grégoire Weber wrote:

> Hi folks,
> 
> I would like to list the contributors of objects but unfortunately 
> the objects Contributors lists returned by a search are always empty 
> (debug_1, see stripped code below). 'Creator' works as expected (debug_2).
> 
> I could fetch and print them in the objects view method (e.g. 
> document_view). So I know the contributors are saved in the zodb.
> 
> I do not understand why it does not work! It should be simple!
> 
> Any pointers from somebody on the list?
> Do you see the obvious mistake I made (if any)?
> 
> Greg
> 
> stripped code::
> 
>   <dtml-let items="portal_catalog.searchResults()">
>     <dtml-in items>
>       a lot of code ...<br>
>       debug_1:::<dtml-var Contributors>:::<br>
>       debug_2:::<dtml-var Creator>:::
>       <dtml-in Contributors>
>         <dtml-let contributor_name="_['sequence-item']">
>           <dtml-var contributor_name>,
>         </dtml-let>
>       </dtml-in>
>     </dtml-in>
>   </dtml-let>


An important gotcha here:  you are iterating over the "brains"
objects returned from a catalog query, rather than over the content
objects themselves.  "Brains" objects know only about the "cached"
metadata in the catalog;  you must call 'getobject' on them (and
take the rather large performance penalty) to get access to non-cached
attributes.

Unlike the other fields you are displaying, 'Contributors' is not

part of the metadata which is cached in the 'portal_catalog;  the
value you are seeing is therefore the 'Contributors' of the CMFSite
(I would guess).

Add the 'Contributors' column on the "Schema" tab of your catalog,
update the catalog, and try again.


Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com