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

2006-05-30 Thread Frank Burkhardt
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_urlasdf/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
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2006-05-30 Thread Achim Domma

Mats Nordgren wrote:


context/articles would return the id's

[...]

The id is a string which has a title method (capitalize each worlds first
letter); this is why your article/title is working.

[...]

You probably should use context/articles/values for the loop.


Thanks, it works now. The availability of 'title' confused me. I didn't 
knew about this method.


regards,
Achim

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2006-05-29 Thread Garanin Michael
В Пнд, 29/05/2006 в 20:26 +0200, Achim Domma пишет:
 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_urlasdf/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.
 
What is 'articles'? I can think 'articles' is list of dictionarys, like
[ {'title':'bla-bla', ...} , ..., {'title':'bla-bla'}]. 

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2006-05-29 Thread Mats Nordgren
Achim,

context/articles would return the id's

 d = {'one':1, 'two':2}
 for item in d:
... item
... 
'one'
'two'

The id is a string which has a title method (capitalize each worlds first
letter); this is why your article/title is working.

 for item in d:
... item.title()
... 
'One'
'Two'

You probably should use context/articles/values for the loop.

Cheers,

Mats

 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_urlasdf/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.

 Am I missing something?

 regards,
 Achim
 ___
 Zope3-users mailing list
 Zope3-users@zope.org
 http://mail.zope.org/mailman/listinfo/zope3-users

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users