Zope bug or my stupidity?
...I'm betting on the latter :) The problem in a nutshell is that a dtml method seems to be returning itself (that is, the dtml source of the method), rather than what it ought to be returning. I have two classes, a "Topic" class, derived from ObjectMananger, and a "Story" class. The Topics contain Stories. As you might imagine, I wanted a method that would dig up the most recent stories in a Topic. So I wrote one and put it in the the methods of the Topic class. Done with that, I wanted a method that would decide which of the Stories from each topic to put on the main page. But a weird thing happened. I got errors telling me that my function was returing a string (I was trying to use it in a dtml-in tag). That's odd, I thought, so changed the function to simply spit out the results of the method call with a dtml-var tag. I discovered that it was spitting out the source of my dtml method. Yikes! Aren't all variables supposed to be rendered? Here's the method (named get_storys) in the Topic's methods: <dtml-call "REQUEST.set('stories', [])"> <dtml-in "objectValues('Story')" reverse sort=Date> <dtml-if numStories> <dtml-if "sequence-index < (numStories - 1)"> <dtml-call "stories.append(id)"> </dtml-if> <dtml-else> <dtml-if "sequence-index == 0"> <dtml-call "stories.append(id)"> </dtml-if> </dtml-if> </dtml-in> <dtml-return stories> Here's the method that calls that method: <dtml-in "objectValues('Topic')"> <dtml-with sequence-item> <dtml-var "get_storys"> </dtml-with> </dtml-in> <dtml-with "Economic.ColdFusion"> <dtml-var id> </dtml-with> In case you're wondering, I'm running zope 2.2.0. ===== Peter Hernberg An all-purpose, antibacterial, lemon-scented geek/nerd "If there were a nation of Gods,it would govern itself democratically. A government so perfect is not suited to men." --Jean-Jacques Rousseau __________________________________________________ Do You Yahoo!? Yahoo! Mail � Free email you can access from anywhere! http://mail.yahoo.com/
Always bear in mind that anything inside double quotes gets executed as python. Therefor, the followign lines are not doing what you intend: Peter Hernberg wrote:
<dtml-if "sequence-index < (numStories - 1)"> <dtml-if "sequence-index == 0">
try these instead: <dtml-if "_['sequence-index'] < (numStories - 1)"> <dtml-if "_['sequence-index'] == 0"> cheers, Chris
<dtml-let complaint="'why-did-we-decide-to-use-hyphens-anyway'">? <dtml-call "REQUEST.set('solution', 'we_should_have_used_underscores_instead')"> -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Chris Withers Sent: Tuesday, August 15, 2000 9:02 AM To: petehern@yahoo.com Cc: zope@zope.org Subject: [Zope] <dtml-var "python goes here!"> Always bear in mind that anything inside double quotes gets executed as python. Therefor, the followign lines are not doing what you intend: Peter Hernberg wrote:
<dtml-if "sequence-index < (numStories - 1)"> <dtml-if "sequence-index == 0">
try these instead: <dtml-if "_['sequence-index'] < (numStories - 1)"> <dtml-if "_['sequence-index'] == 0"> cheers, Chris _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Chris Withers -
Peter Hernberg -
T.J. Mannos