I used my small test-program and the admin-application.

Yes, now I can change an existing record without an error.
And a wrong email-address show an appropriate message.

Then I tried to add a new row and I got:
<type 'exceptions.TypeError'> object of type 'NoneType' has no len()

Function argument list

(cls=<class 'gluon.sqlhtml.ListWidget'>, field=<gluon.dal.Field object>,
value=None, **attributes={'_style': 'list-style:none'})
 Code listing


243.
244.
245.
246.
247.
248.

249.
250.
251.
252.


            field.requires, (IS_NOT_EMPTY, IS_LIST_OF)) else None

        attributes['_style'] = 'list-style:none'
        items = [LI(INPUT(_id=_id, _class=_class, _name=_name,

                          value=v, hideerror=k<len(value)-1,

                          requires=requires),
                    **attributes)  for (k,v) in enumerate(value or [''])]

        script=SCRIPT("""

// from http://refactormycode.com/codes/694-expanding-input-list-using-jquery
(function(){
jQuery.fn.grow_input = function() {



2012/9/16 Massimo Di Pierro <massimo.dipie...@gmail.com>

> You opened a pyfpdf issue. You may want to close it.


Ooops - sorry!

>
> I moved it to web2py issue 1010 and I think I have a fix in trunk. Can you
> check?
>
> http://code.google.com/p/web2py/issues/detail?id=1010
>
>
> On Sunday, 16 September 2012 01:03:19 UTC-5, mweissen wrote:
>
>> Done: Issue 29 <https://code.google.com/p/pyfpdf/issues/detail?id=29>: on
>> error IS_LIST_OF() changes the value of INPUT
>>
>> 2012/9/16 Massimo Di Pierro <massimo....@gmail.com>
>>
>> Definitively a problem with the widget. Please open a ticket about it.
>>>
>>>
>>> On Saturday, 15 September 2012 17:01:44 UTC-5, mweissen wrote:
>>>
>>>> Sorry, I did not mention:
>>>> I did not use a form, I have used the admin interface to insert and
>>>> update the records.
>>>> I have tried it twice: first with my "real" program and second with the
>>>> small program I have sent.
>>>>
>>>> Now I have added this function:
>>>>
>>>> def em():
>>>>     form=SQLFORM(db.address)
>>>>     if form.process().accepted:
>>>>         response.flash='ok'
>>>>     elif form.errors:
>>>>         print form.errors
>>>>     return dict(form=form)
>>>>
>>>> ... and used it to add two wrong email-addresses:
>>>> aa
>>>> bb
>>>>
>>>> I did not get an error messege below the fields, but the flash "Errors
>>>> in form, please check it out" and both fileds look like
>>>> ['aa', 'bb']
>>>>
>>>>
>>>> 2012/9/15 Massimo Di Pierro <massimo....@gmail.com>
>>>>
>>>>> I cannot reproduce this:
>>>>>
>>>>> >>> IS_EMAIL()('x')
>>>>> ('x', 'enter a valid email address')
>>>>> >>> IS_EMAIL()('x...@x.com')
>>>>> ('x...@x.com', None)
>>>>> >>> IS_LIST_OF(IS_EMAIL())(['x'])
>>>>> (['x'], 'enter a valid email address')
>>>>> >>> IS_LIST_OF(IS_EMAIL())(['x...@**x.**com'])
>>>>> (['x...@x.com'], None)
>>>>> >>> IS_LIST_OF(IS_EMAIL())(['x#x.**c**om <http://x.com>'])
>>>>> (['x#x.com'], 'enter a valid email address')
>>>>>
>>>>> can your print form.errors? Perhaps this is a problem with the widget
>>>>> and not the validator.
>>>>>
>>>>> On Saturday, 15 September 2012 13:08:50 UTC-5, mweissen wrote:
>>>>>
>>>>>> I have a simple table, one name and a list of email-addresses:
>>>>>>
>>>>>> db.define_table('address',
>>>>>>     Field('name'),
>>>>>>     Field('emails','list:string', requires=IS_LIST_OF(IS_EMAIL()*****
>>>>>> *)))
>>>>>>
>>>>>> Now I add one name and two email-addresses to this table.
>>>>>>
>>>>>> Id:      1
>>>>>> Name:    Smith
>>>>>> Emails:  jsm...@example.com
>>>>>>          j...@example.com
>>>>>>
>>>>>> Everything looks fine.
>>>>>>
>>>>>> But if there is an error in the email-address (which is catched by
>>>>>> the validator), a lot goes wrong:
>>>>>> Both email-addresses are converted to a list; this list is doubled and
>>>>>> ...
>>>>>>
>>>>>> Id:      1
>>>>>> Name:    Smith
>>>>>> Emails:  ['jsmith*#*example.com', 'j...@example.com']
>>>>>>          ['jsmith#example.com', 'j...@example.com']
>>>>>>
>>>>>> ... there is no error message!
>>>>>>
>>>>>> Now I have changed the model to
>>>>>>
>>>>>> db.define_table('address',
>>>>>>     Field('name'),
>>>>>>     Field('emails','list:string', requires=IS_EMAIL()))
>>>>>>
>>>>>> but this model does not detect the wrong email address.
>>>>>>
>>>>>> What is the right way to use a validator with a list of strings?
>>>>>>
>>>>>> Regards, Martin
>>>>>>
>>>>>
>>>>>
>

-- 



Reply via email to