How can folder address its contents?
I want to iterate over the contents of a folder. I can't do it by name, since items will be added and taken out of the folder at run time, so I don't know what they'll be called. I think I'll figure out the iteration ok, but how do I get at the objects contained in a folder, other than by name? -- . . . . . . . . . . . . . . . . . . Bob Erb . . I don't want to die today!
Try something like <dtml-in foldername> <dtml-var id> <dtml-else> Nothing in folder. </dtml-in> Phil phil.harris@zope.co.uk ----- Original Message ----- From: Robert W. Erb <rerb@progress.com> To: <zope@zope.org> Sent: Sunday, December 12, 1999 7:06 PM Subject: [Zope] How can folder address its contents?
I want to iterate over the contents of a folder. I can't do it by name, since items will be added and taken out of the folder at run time, so I don't know what they'll be called.
I think I'll figure out the iteration ok, but how do I get at the objects contained in a folder, other than by name?
-- . . . . . . . . . . . . . . . . . . Bob Erb . . I don't want to die today!
_______________________________________________ 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 )
On Sat, 11 Dec 1999, Phil Harris wrote:
Try something like
<dtml-in foldername> <dtml-var id> <dtml-else> Nothing in folder. </dtml-in>
I just tried this on my Zope and, unless I did something wrong, it did not work. It failed with: Error Type: TypeError Error Value: hasattr, argument 2: expected string, int found What has always worked for me is: <dtml-in "foldername.objectValues()"> <dtml-var id> <dtml-else> Nothing in folder. </dtml-in> If you want only the folders contained in foldername: <dtml-in "foldername.objectValues(['Folder'])"> ... </dtml-in> If you want folders and DTML Methods: <dtml-in "foldername.objectValues(['Folder', 'DTML Method'])"> ... </dtml-in> And so on. --Jeff
On Sun, Dec 12, 1999 at 02:06:38PM -0500, Robert W. Erb wrote:
I want to iterate over the contents of a folder. I can't do it by name, since items will be added and taken out of the folder at run time, so I don't know what they'll be called.
I think I'll figure out the iteration ok, but how do I get at the objects contained in a folder, other than by name?
Something like this should work. <dtml-in objectItems> <dtml-var "_['sequence-item'].title"> </dtml-in> Beware of the sequence-item snafu; to use it in expressions, you must refer to it as _['sequence-item']! Anyone know why this is? -- Stephen Pitts smpitts@midsouth.rr.com webmaster - http://www.mschess.org
----- Original Message ----- From: Stephen Pitts <smpitts@midsouth.rr.com> To: Robert W. Erb <rerb@progress.com> Cc: <zope@zope.org> Sent: Monday, December 13, 1999 2:21 AM Subject: Re: [Zope] How can folder address its contents? ..<snipped>..
Beware of the sequence-item snafu; to use it in expressions, you must refer to it as _['sequence-item']! Anyone know why this is?
This is (probably) because as an expression 'sequence-item' is interpreted as 'sequence' - 'item' (subtraction). You can <dtml-let si=sequence-item> and than use si in expressions without any problem. Or, you can use _['sequence-item'] like you mention, which indexes the namespace directly. (Wonder why its not sequence_item, which wouldn't have caused any such problem?) ~Shalabh ----------------------------------------------------------------------- Good programmers know what to write. Great ones know what to rewrite. --Eric Raymond -----------------------------------------------------------------------
participants (5)
-
Jeff K. Hoffman -
Phil Harris -
Robert W. Erb -
Shalabh Chaturvedi -
Stephen Pitts