[Zope3-Users] Problem with containment and @@absolut_url

Frank Burkhardt fbo2 at gmx.net
Tue May 30 02:31:21 EDT 2006


Hi,

On Mon, May 29, 2006 at 08:26:38PM +0200, Achim Domma wrote:
> Hi,
> 
> I have implemented ArticleFolder and Article like this:
> 
> 
> class Article(Persistent,Contained):
>     implements(IArticle)
>     title=u''
>     body=u''
> 
> class ArticleFolder(Folder):
>     implements(IArticleFolder)
> 
> 
> Via ZMI I can add, edit and delete articles without problems. I use this TAL statement in a view 
> for the object holding the article folder :
> 
> <p tal:repeat="article context/articles">
>     <a
>        tal:content="article/title"
>        tal:attributes="href article/@@absolute_url">asdf</a>		
> </p>
> 
> This fails with an "There isn't enough context to get URL information." exception. When the 
> exception is thrown, I see in the debugger, that the context of AbsoluteUrl is the id of the first 
> article as unicode string. And this string has of course no __parent__ attribute!?
> 
> I argued that context/articles might return ids, not objects, but in that case article/title 
> should fail also. But if I remove tal:attributes, it works fine.

Remembering your last problem with Object()-schema, my guess is that you
stored your articles as a list ob Object()s in an articlefolder's
'articles'-attribute. This way a single article doesn't have an URL - it's
just an attribute - no matter which base classes (->Contained) you use.
You've got two options:

   1. A view on articlefolder that take some arguments and displays a given
      article.  You'd have to use something like this then:
       <a ... tal:attributes="href ${context/@@absolute_url}/articleview?${article/title}" ... />
   2. Write your own traversal adapter that displays objects in lists like this:
       <a ... tal:attributes="href ${context/@@absolute_url}/++article++${article/title}" ... />

If I were you, I'd take option one (if I guessed your problem right :-) ).

Regards,

Frank


More information about the Zope3-users mailing list