The problem is the first time your for loop runs it will return to the dtml
and will not run anymore.

Rather build up a list, or list of objects inside your method and then
return. Dtml-in needs to see a list.

  Andy McKay, Developer.
----- Original Message -----
From: "Tim Hicks" <[EMAIL PROTECTED]>
Sent: Monday, November 06, 2000 12:45 PM
Subject: [Zope] dtml-in over the output from my method

I am trying to create a zope product in python but have got stuck with using
the dtml-in tag to iterate over a method (or is it a function? I get a
little mixed up) of my class. Here is the method,

        def list_messages(self):
                lr = open(self.user_dir+'/msg_list', 'r')
                spl = re.compile('\s\|\s')
                for msg_line in lr.readline():
                        num_from_sub = []
                        num_from_sub = spl.split(msg_line, 2)
                        print num_from_sub
                        self.msgnum = num_from_sub[0]
                        self.msgfrom = 'This is from UNKNOWN'
                        self.msgsub = 'My special subject'
                        return self.msgnum, self.msgfrom, self.msgsub

And here is an extract from the dtml file that is supposed to display the

<dtml-in list_messages>

However, this does not produce the desired effect. I don't know if it is
obvious from what I've written, but basically, the three variables
(self.msgnum, self.msgfrom and self.msgsub) are supposed to be inserted into
the appropriate place in the table, and then the 'for' statement re-executed
(producing different values for the variables) with the subsequent values
being inserted into the next line of the table etc... until there are no
more lines to be read from lr. I'm not sure if that is clear or not, sorry.
Obviously, this does not work as the dtml-in simply iterates over each of
the returned variables (instead of over the for statement). I can't seem to
make it do what I want. Does anyone have any ideas? Much obliged if you do.



Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to