[Zope-CMF] Problems making a links_box
Tres Seaver
tseaver@zope.com
27 Jun 2002 15:09:04 -0400
On Thu, 2002-06-27 at 10:02, Ronald L Roeber wrote:
> I'm attempting to make a links_box modeled after news_box (Zope: 2.5.1,
> CMF 1.2.
>
> Here is the test code:
>
> ------------------------------------
> <span tal:define="my_links python: here.portal_catalog(meta_type='Link'
> , sort_on='Date'
> ,
> sort_order='reverse'
> ,
> review_state='published')">
> <span tal:repeat="link my_links">
> <a href="http://www.dummylink.net" class="menu"
> tal:attributes="href link/remote_url"
> tal:content="link/title">An Interesting Link</a><br>
> </span>
> </span>
> ---------------------------------
> I get the following error at the end of the traceback:
>
> Undefined: remote_url not found in 'link/remote_url', at line 6, column 3
>
> If I omit the tal:attributes or use something like "href link/id" then I
> don't get the error, but of course the link is incorrect.
>
> Are not the objects returned from the catalog search the same type as the
> original (Link)?
Nope; they are "brains", which hold the cached metadata for the
catalogued object and provide access to it.
> could someone point me in the right direction? Thanks.
You can either:
- Add a column, 'remote_url', to the "Schema" tab of your catalog,
and then reindex everything; the "brains" will then have that
attribute. This option gives better performance, because the
page doesn't need to "wake up" the Link objects in order to render.
- Use the "brain" to get to the underlying object, using its
'getObject' method; this will run slower, because 'getObject'
"wakes up" the underlying object.
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com