[Zope-CMF] Formatting in <textarea>

Vasily Butorin Vasily Butorin <vasil@doublesquare.com>
Thu, 5 Jun 2003 11:49:30 +0400


Thursday, June 05, 2003, 12:58:09 AM, Kendrick Conner wrote:

KC> On my zope page I have comment area that uses <TEXTAREA type=3Dtext n=
ame=3D"sig_description" cols=3D"60" rows=3D"5">
KC> </textarea></p>=A0
KC>=20
KC> to create the area where they add comments, but the lines are
KC> wrapped even if you use the enter key to seperate the lines.=A0 On
KC> the back end is MySQL.=A0 Basically you cannot do any formatting
KC> that stays.=A0 System is running on Linux RH 8.=A0 I can seem to find
KC> anything that deals with this type of text formatting and I own
KC> several zope books.=A0 Please Help!

"New line" characters ('\n') in your text will be lost if you save it
into db using ZSQLMethod. All '\n' in the SQL query are replaced with
spaces (' ').


workaround:
replace '\n' with '\\012' in your text before you send them into
ZSQLMethod, for example:

  sig_description =3D '\\012'.join(sig_description.split('\n'))
  SQL_method(sig_description)

It works for me with PostgreSQL, I think it will do with MySQL too.

--=20
 Vasily