[Zope] textarea/newline-mess

Page Page page@hotmail.ro
Thu, 27 Jun 2002 22:18:34 +0300


Gang,
I have a textarea-form here that looks like this:

<form action="manage_addTEXT" blabla...
<textarea blabla>
</textarea blabla>
</form>

The function

   manage_addTEXT(self, TEXT="")

gets the text from textarea as string in TEXT.
It splits the text by using 

   string.split(TEXT, '\n') 

into lines and stores each line in a database.
For editing the TEXT I use a .dtml-script that re-assembles
the text line by line:

    <textarea><dtml-in sqlFetchTEXT><dtml-var LINE></textarea>

Please note, that I write it all without any spacing between 
the tags. One could think that this results in having the
lines being displayed in the textarea like this:

    Line00Line01Line02Line03

but thats not the case. For some reason we see
    Line00
    Line01
    Line02
    Line03

How's that possible? string.split() removed all the newlines. 
If I check the database via

   select LINES from TEXTBASE

I see that each line is, in fact, stored separately.

If I call

   manage_addTEXT()

directly, however, i.e. not from a form, and pass a bunch of lines
to it:

   manage_addTEXT(TEXT="ichi\nni\san\nshi\n")

I end up with all lines concatenated into a single line in my
edit-form that so nicely displays the put in via a form.

Why is this so? There must be something about how \ns are 
conveyed via HTTP and how Zope handles it what I don't know.
Theories, anyone?

Thanks
PAGE

______________________________________________________________________
Do you want a free e-mail for life ? Get it at http://www.hotmail.ro/