Issue may be with SQLFORM rather than Pydal - if I have a list string field in my case its called answers and put it in a SQLFORM then in form.validate if you do
print type(form.vars.answers) I get str when there is 1 item in my list and list when multiple answers and so my validation includes a line like this: if isinstance(form.vars.answers, list) and len(form.vars.answers) > 1 and len(form.vars.answers[1]) > 0: I just thought I'd mention it as something to be aware of if you start using length with list string fields as I always expected it to be a list. This is still the case with 2.16.1 Donald On Friday, November 17, 2017 at 11:47:49 PM UTC, Anthony wrote: > On Friday, November 17, 2017 at 3:53:02 PM UTC-5, Donald McClymont wrote: > >> I don’t think you can set this but not sure why you would want to. >> However beware if testing the length of the field as I think if you only >> have 1 item in the list then this is a string and you get the number of >> chars in the string. While if you have more than 1 you get the length of >> the list. > > > Can you show some code demonstrating what you mean -- I cannot replicate? > If you use the DAL to select data, it automatically converts the native > data to a Python list, even if the list includes only a single item. So, if > you do something like len(db.mytable(1).my_list_string_field), you should > always get the length of the list, not the length of any single element in > the list. > > Anthony > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

