DTML Doc property from DTML Method in tag
Hi, I'm having trouble getting at an DTML Document property from within an in tag in a DTML Method. I have a folder property that lists the documents I want to appear in a particular order. I would like to display the "title" and "summary" of those documents. <!--#in docs--> <p><!--#var ???--></p> <!--#/in--> So, if the docs list contained an entry "test", what would I put in the var tag to get test.title? If I use "test.title", I get the title. If I try "sequence-item+'.title'" or "_[sequence-item+'.title']", I get a NameError. What simple little thing am I missing here? Thanks, Kevin -- Kevin Dangoor kid@ans.net / 734-214-7349
Kevin Dangoor wrote:
I'm having trouble getting at an DTML Document property from within an in tag in a DTML Method. I have a folder property that lists the documents I want to appear in a particular order. I would like to display the "title" and "summary" of those documents.
<!--#in docs--> <p><!--#var ???--></p> <!--#/in-->
So, if the docs list contained an entry "test", what would I put in the var tag to get test.title? If I use "test.title", I get the title. If I try "sequence-item+'.title'" or "_[sequence-item+'.title']", I get a NameError. What simple little thing am I missing here?
I may be wrong here as this involved a subobject of an object, however, I suggest you try simply: <!--#in docs--> <p><!-- #var title--></p> <!--#/in--> The namespace inside #in changes to that of sequence-item. This is documented in the Zope DTML User's guide (page 11, name lookup, I suspect), but (hint) an "idiot's guide to DTML name lookup" would be useful. I myself found out about this through experimentation. :) Regards, Martijn
I don't think so. Which "title" are you referencing? I have a very similar problem. In a form, I generate a list of 'ids' (just like the manage screens). When processing that form, I call "manage_delObjects" just fine. However, before doing so, I would like to generate a report. That report needs to list not the 'id', but the 'common_name' of the item. -- -- snip -- -- <!--#in ids--> <P><!-- This gets the ID --> <!--#var sequence-item--> <!-- But this gives a key error --> <!--#var common_name--> <!--#/in--> <!-- This is fine if I don't make the above error --> <!--#call "manage_delObjects(REQUEST=REQUEST, ids=ids)"--> -- -- snip -- -- On Mon, 15 Feb 1999, Martijn Faassen wrote:
Kevin Dangoor wrote:
I'm having trouble getting at an DTML Document property from within an in tag in a DTML Method. I have a folder property that lists the documents I want to appear in a particular order. I would like to display the "title" and "summary" of those documents.
<!--#in docs--> <p><!--#var ???--></p> <!--#/in-->
So, if the docs list contained an entry "test", what would I put in the var tag to get test.title? If I use "test.title", I get the title. If I try "sequence-item+'.title'" or "_[sequence-item+'.title']", I get a NameError. What simple little thing am I missing here?
I may be wrong here as this involved a subobject of an object, however, I suggest you try simply:
<!--#in docs--> <p><!-- #var title--></p> <!--#/in-->
The namespace inside #in changes to that of sequence-item. This is documented in the Zope DTML User's guide (page 11, name lookup, I suspect), but (hint) an "idiot's guide to DTML name lookup" would be useful. I myself found out about this through experimentation. :)
It does not seem to do so for me.
Richard Wackerbarth wrote:
I don't think so. Which "title" are you referencing?
The title of sequence-item (provided it has one). If outside an #in, 'title' would refer to the title of the folder (if any), I think.
I have a very similar problem.
In a form, I generate a list of 'ids' (just like the manage screens). When processing that form, I call "manage_delObjects" just fine. However, before doing so, I would like to generate a report. That report needs to list not the 'id', but the 'common_name' of the item.
-- -- snip -- --
<!--#in ids--> <P><!-- This gets the ID --> <!--#var sequence-item--> <!-- But this gives a key error --> <!--#var common_name--> <!--#/in--> <!-- This is fine if I don't make the above error --> <!--#call "manage_delObjects(REQUEST=REQUEST, ids=ids)"-->
Is common_name an attribute of an id object? I think if it is, <!#--#var common_name--> ought to work in the #in. At least that is how it appears to work for me. But I admit I'm muddled about this too. Figure 2 on page 21 of the Zope Document Template Markup Language User's Guide (what a title!) seems to confirm it, though. Regards, Martijn
this is my structure: Folder 'HERE' has Folders within it. Assume that they have ids ID1, ID2, ID3, etc. Each of these Folders has a property 'common_name' Thus, in HERE/ID1 can reference <!--#var common_name--> and get 'Name 1'. In HERE, I execute a form. The checkboxes build a list ids ['ID1', 'ID2']. Processing the form, <!--#var ids--> gives me the list. <!--#in ids--><!--#var sequence-item--><!--#/in--> gives 'ID1' on the first iteration. But I want to get 'Name 1' On Mon, 15 Feb 1999, Martijn Faassen wrote:
Richard Wackerbarth wrote:
I don't think so. Which "title" are you referencing?
The title of sequence-item (provided it has one). If outside an #in, 'title' would refer to the title of the folder (if any), I think.
I have a very similar problem.
In a form, I generate a list of 'ids' (just like the manage screens). When processing that form, I call "manage_delObjects" just fine. However, before doing so, I would like to generate a report. That report needs to list not the 'id', but the 'common_name' of the item.
-- -- snip -- --
<!--#in ids--> <P><!-- This gets the ID --> <!--#var sequence-item--> <!-- But this gives a key error --> <!--#var common_name--> <!--#/in--> <!-- This is fine if I don't make the above error --> <!--#call "manage_delObjects(REQUEST=REQUEST, ids=ids)"-->
Is common_name an attribute of an id object? I think if it is, <!#--#var common_name--> ought to work in the #in. At least that is how it appears to work for me. But I admit I'm muddled about this too. Figure 2 on page 21 of the Zope Document Template Markup Language User's Guide (what a title!) seems to confirm it, though.
On Mon, Feb 15, 1999 at 10:53:48AM +0100, Martijn Faassen wrote: ,----- | Kevin Dangoor wrote: | > | > I'm having trouble getting at an DTML Document property | > from within an in tag in a DTML Method. I have a folder property | > that lists the documents I want to appear in a particular order. | > I would like to display the "title" and "summary" of those documents. | > | > <!--#in docs--> | > <p><!--#var ???--></p> | > <!--#/in--> | > | > So, if the docs list contained an entry "test", what would I put in | > the var tag to get test.title? If I use "test.title", I get the | > title. If I try "sequence-item+'.title'" or "_[sequence-item+'.title']", | > I get a NameError. What simple little thing am I missing here? | | I may be wrong here as this involved a subobject of an object, however, | I suggest you try simply: | | <!--#in docs--> | <p><!-- #var title--></p> | <!--#/in--> | | The namespace inside #in changes to that of sequence-item. This is | documented in the Zope DTML User's guide (page 11, name lookup, I | suspect), but (hint) an "idiot's guide to DTML name lookup" would be | useful. I myself found out about this through experimentation. :) I think this would work if docs was a group of actual objects. However, docs is a "lines" Folder property. So, the sequence-item is just a string. If I say: <!--#var "sequence-item + '.title'"-->, it will say "test.title". However, I can seem to get it to actually track down test.title as if I had done: <!--#var test.title--> (BTW, I tried the example you gave and it prints the Folder's title.) Kevin | | Regards, | | Martijn | | _______________________________________________ | Zope maillist - Zope@zope.org | http://www.zope.org/mailman/listinfo/zope `----- -- Kevin Dangoor UUnet Technologies kid@ans.net / 734-214-7349
Kevin Dangoor wrote:
On Mon, Feb 15, 1999 at 10:53:48AM +0100, Martijn Faassen wrote:
[my suggestion snipped]
I think this would work if docs was a group of actual objects. However, docs is a "lines" Folder property. So, the sequence-item is just a string.
Aah, I see what you want now. Sorry to give the wrong suggestions.
If I say: <!--#var "sequence-item + '.title'"-->, it will say "test.title". However, I can seem to get it to actually track down test.title as if I had done: <!--#var test.title-->
You can or you can't? (typo?) Wasn't there some mention of a 'secret method' called render a while back? Something like: "_.render(sequence-item + '.title')" might do the trick?
(BTW, I tried the example you gave and it prints the Folder's title.)
Yes, it would if it couldn't find any other title, of course. Regards, Martijn
On Mon, Feb 15, 1999 at 07:28:41PM +0100, Martijn Faassen wrote: ,----- | Kevin Dangoor wrote: | > | > On Mon, Feb 15, 1999 at 10:53:48AM +0100, Martijn Faassen wrote: | [my suggestion snipped] | | > I think this would work if docs was a group of actual objects. However, | > docs is a "lines" Folder property. So, the sequence-item is just a string. | | Aah, I see what you want now. Sorry to give the wrong suggestions. | | > If I say: | > <!--#var "sequence-item + '.title'"-->, it will say "test.title". | > However, I can seem to get it to actually track down test.title | > as if I had done: | > <!--#var test.title--> | | You can or you can't? (typo?) Can't... That was indeed a typo. | Wasn't there some mention of a 'secret method' called render a while | back? Something like: | | "_.render(sequence-item + '.title')" | | might do the trick? Good thought. I gave it a try, and that DTML above gives an error. This DTML: _.render(_['sequence-item'] + '.title') displays "test.title" rather than the title itself. | > (BTW, I tried the example you gave and it prints the Folder's title.) | | Yes, it would if it couldn't find any other title, of course. That makes sense. | | Regards, | | Martijn `----- Kevin -- Kevin Dangoor kid@ans.net / 734-214-7349
Kevin Dangoor wrote: | I'm having trouble getting at an DTML Document property | from within an in tag in a DTML Method. I have a folder property | that lists the documents I want to appear in a particular order. | I would like to display the "title" and "summary" of those documents. | | <!--#in docs--> | <p><!--#var ???--></p> | <!--#/in--> You need to request a list of objects and display their attributes. Here's a (slightly hackoid) version of what I often do. <!--#in med_list--> <!--#var name--> <!--#var dosage--> <!--#freq--><br> <!--#/in--> --- def med_list(self): """medication list""" class _Med: def __init__(self, name, dosage, freq): self.name = name self.dosage = dosage self.freq = freq medList = [] for (n, d, f) in self.getMedicationsDosagesFrequencies(): medList.append(_Med(n,d,f)) return medList While were on the subject, however, I was wondering if there might be a convenient way to pass a list of dictionaries and use its keys as attributes directly in an <!--#in--> block. Best regards, Jeff Bauer Rubicon, Inc.
participants (4)
-
Jeff Bauer -
Kevin Dangoor -
Martijn Faassen -
Richard Wackerbarth