I found a solution to avoid the error
using the validator MaxLength(maxlength=500),
in this way I can enter 496 characters in the textarea using the keyboard
but when I submit data I get this error:
{'description': 'Please enter a value less than 500 characters long'}
then I delete4 characters, and only when  have 492 characters I can save
data to DB
j


On 02/18/2013 02:59 PM, Jose Soares wrote:
Hi all,

I think I found a bug in TextArea widget.
I defined the following widget: (note the maxlength of 500 characters)


    widgets.TextArea(
                     name = "descrizione",
                     label=_('descrizione:'),
                     default = "",
                     rows    = 5,
                     cols    = 100,
                     validator = v.String(strip=True),
                     attrs   = dict(maxlength=500))

I tried to insert five rows of 100 characters each, like this:

1..................................................................................................|
2..................................................................................................|
3..................................................................................................|
4..................................................................................................|
5...............................................................................................

as you can see I couldn't insert more than 96 characters in the (6th) last row, seems it consider a newline character for lines 1 thru 4.

when I try to save data to the DB it raises the error: (the column descrizione is length 500)

*DataError: ('(DataError) value too long for type character varying(500)\n'

*
Here is the value it is trying to insert into DB:

"1..................................................................................................|\r\n
2..................................................................................................|\r\n
3..................................................................................................|\r\n
4..................................................................................................|\r\n
5..............................................................................................."

as you can see there are two extra characters at the end of each line instead of only one,
thus the total number of characters is 504 instead of 500.

What can I do to avoid this error?
thanks for any help
j

--
You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to