[Zope] Returning results from pythod method to web page
Ivan Cornell
ivan.cornell@framestore.co.uk
Fri, 16 Mar 2001 10:36:10 +0000
Hi Alan,
I advocate separating logic [python] & presentation [dtml], so create
[something like] the following python script:
result = []
while (i < length):
result.append(splitString[i])
i = i + 1
return result
but I've just reread your message as I don't quite understand what
stringSplit is, so why don't you just return the list as is:
return stringSplit
then in dtml:
<dtml-in myScript>
<option>&dtml-sequence-item
</dtml-in>
Ivan
ps please send plain text mail to this list
> Hi there, I'm trying to find a way of returning some results from a
> MySQL database search into a <OPTION> </OPTION> list in a web
> page. I've written a python method which gets all the data i need from
> my database. I've stripped down the results (ie removed all the double
> and single quotes) so i can split them into the individual
> results. Heres my problem, i've got a while loop that will loop
> through each of the results from my database query, but i need some
> way to pass these results out to my web page. I've tried using: while
> (i<length):
> return " <option value=\" "+splitString[i]+" \">"+splitString[i]+"
> " i = i + 1 Which works but as it uses Return it fall out the loop
> and only returns the one item in my OPTION list. So i then tried to
> return a string of all the search results such as: while (i<length):
> f = " <option value=\" "+splitString[i]+" \">"+splitString[i]+" "
> i = i + 1
> s = f
> s = s + f
> return s which returns the last item of the seach results. I've worked
> out that it does this because i keep overwriting the value of s with
> f. I've tried to assign s to be empty or " " but i was getting error
> messages saying s has not been assigned any values. Does anyone know
> how i could get around this? or does anyone know a better way of
> returning values from a loop into a web page?? Any feedback
> (preferably ASAP) would be most apprieciated Cheers Alan
>