Re: [Zope] Zope bug or my stupidity?
Peter Hernberg wrote: Here's the method that calls that method: dtml-var "get_storys" Why the quotes? try dtml-var get_storys instead cheers, Chris ___ Zope maillist - [EMAIL PROTECTED] 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 )
[Zope] 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/ ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] Zope bug or my stupidity?
--- Chris Withers [EMAIL PROTECTED] wrote: Peter Hernberg wrote: Here's the method that calls that method: dtml-var "get_storys" Why the quotes? try dtml-var get_storys instead But then I get the following weird error: Traceback (innermost last): File /root/Zope-2.2.0-src/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /root/Zope-2.2.0-src/lib/python/ZPublisher/Publish.py, line 187, in publish File /root/Zope-2.2.0-src/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: ApplicationDefaultPermissions) File /root/Zope-2.2.0-src/lib/python/ZPublisher/Publish.py, line 171, in publish File /root/Zope-2.2.0-src/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: get_stories) File /root/Zope-2.2.0-src/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: get_stories) File /root/Zope-2.2.0-src/lib/python/OFS/DTMLMethod.py, line 167, in __call__ (Object: get_stories) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: get_stories) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_In.py, line 691, in renderwob (Object: objectValues('Topic')) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: sequence-item) File /root/Zope-2.2.0-src/lib/python/OFS/DTMLMethod.py, line 163, in __call__ (Object: get_storys) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: get_storys) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_In.py, line 691, in renderwob (Object: objectValues('Story')) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval (Object: sequence-index == 0) (Info: index) File string, line 0, in ? NameError: (see above) I am fairly new to zope, but this seems pretty weird, especially the method returning its dtml source. = 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/ ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] Zope bug or my stupidity?
On Wed, 16 Aug 2000, Peter Hernberg wrote: --- Chris Withers [EMAIL PROTECTED] wrote: Peter Hernberg wrote: Here's the method that calls that method: dtml-var "get_storys" Why the quotes? try dtml-var get_storys instead But then I get the following weird error: Traceback (innermost last): *snip* (Object: objectValues('Story')) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval (Object: sequence-index == 0) (Info: index) File string, line 0, in ? NameError: (see above) I am fairly new to zope, but this seems pretty weird, especially the method returning its dtml source. And you've been caught by one of the most common (and understandable) newbie mistakes. (o8. 'sequence-item' is not a valid Python name. To Python it looks like " sequence - item ", the mathematical expression. This is a holdover from days of old, and not much has been done to deprecate it (all my shouting, and that of others, has so far come to naught.) dtml-var sequence-item will work, because that is in Zope Land... no quotes. dtml-var "_['sequence-item']" is the Python Land equivalent. the _[] name space lookup is your friend for this sort of problem. dtml-if "sequence-index (numStories - 1)" should be written as: dtml-if "_['sequence-index'] (numStories -1)" = Peter Hernberg An all-purpose, antibacterial, lemon-scented geek/nerd I guess I should really try to rally people to send this to the collector... Have a better one, Curtis Maloney. dtml-var standard_work_disclaimer ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] Zope bug or my stupidity?
Once again I'll point out that I have a patch that allows sequence_item. I've submitted it to the collector but it was rejected because of the AFAIK not-yet-scheduled "named dtml-in" feature. http://www.zope.org/Members/jfarr/Patches/dtml-in-sv/ --jfarr Hardware, n.: The parts of a computer system that can be kicked. - Original Message - From: Curtis Maloney [EMAIL PROTECTED] To: Peter Hernberg [EMAIL PROTECTED]; Chris Withers [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, August 15, 2000 5:51 PM Subject: Re: [Zope] Zope bug or my stupidity? On Wed, 16 Aug 2000, Peter Hernberg wrote: --- Chris Withers [EMAIL PROTECTED] wrote: Peter Hernberg wrote: Here's the method that calls that method: dtml-var "get_storys" Why the quotes? try dtml-var get_storys instead But then I get the following weird error: Traceback (innermost last): *snip* (Object: objectValues('Story')) File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval (Object: sequence-index == 0) (Info: index) File string, line 0, in ? NameError: (see above) I am fairly new to zope, but this seems pretty weird, especially the method returning its dtml source. And you've been caught by one of the most common (and understandable) newbie mistakes. (o8. 'sequence-item' is not a valid Python name. To Python it looks like " sequence - item ", the mathematical expression. This is a holdover from days of old, and not much has been done to deprecate it (all my shouting, and that of others, has so far come to naught.) dtml-var sequence-item will work, because that is in Zope Land... no quotes. dtml-var "_['sequence-item']" is the Python Land equivalent. the _[] name space lookup is your friend for this sort of problem. dtml-if "sequence-index (numStories - 1)" should be written as: dtml-if "_['sequence-index'] (numStories -1)" = Peter Hernberg An all-purpose, antibacterial, lemon-scented geek/nerd I guess I should really try to rally people to send this to the collector... Have a better one, Curtis Maloney. dtml-var standard_work_disclaimer ___ Zope maillist - [EMAIL PROTECTED] 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 ) ___ Zope maillist - [EMAIL PROTECTED] 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 )