I love Web2py and am using it with great success in my organization.
I have run into a limitation/default that I cannot find how to set.
When using the IS_LIST_OF() validator on a list:string Field, I have not
been able to enter more than 100 entries (SQLFORM.grid) without getting the
generic validator message. "Errors in form, please check it out."
The documentation says that this validator does not return an error. And
the list:string field does not have a default max Length.
Is this a limitation of the validator?
Background:
I am storing 5 digit zip codes in the field. I would prefer not to store
all valid US zip codes in a table and use the IS_IN_DB()validator.
And I like the multiple entry style of the mutiple.widget.
So I am using a custom validator. But I have tried this without the custom
validator just IS_LIST_OF(IS_EMPTY_OR(IS_LENGTH(minsize=5, maxsize=6))) as
well and get the same "Errors in form, please check it out." when I have
more than 100 entries.
I am now using no validator as it is a requirement to have unlimited
entries. This is just asking for trouble though.
Would it be possible to move this field to a separate table (normalize) and
perform a one to many join while still using the multiple.widget in
SQLFORM.grid?
Is there an example of how this would be done?
Thank you for reading!
In the model:
###Add in the Zip validator
class IS_EMPTY_OR_ZIP(object):
def __init__(self, error_message='This is not a 5 digit Zip.'):
self.error_message = error_message
def __call__(self, value):
if value:
if value.isdigit() and len(value) == 5:
return value, None
else:
return value, self.error_message
else:
return value, None
Using the validator:
Field('zips', type='list:string',
label=T('Zips (5 digit)'),
requires=IS_LIST_OF(IS_EMPTY_OR_ZIP())),