Thanks for trying to help. But sorry I don't understand how your theory can 
explain why the 2nd case in my example works and 3rd case didn't.

On Thursday, June 27, 2013 7:45:48 PM UTC+8, viniciusban wrote:
>
> I think this is expected, because the field.requires property exists 
> to be executed in forms and validate_and_insert() only simulates this 
> behaviour. 
>
> On Thu, Jun 27, 2013 at 7:30 AM, Ray (a.k.a. Iceberg) 
> <ice...@qq.com<javascript:>> 
> wrote: 
> > Hi community, 
> > 
> > I'm working with web2py, again. :-) 
> > 
> > It took me hours today to realize validate_and_insert(field1=value1, 
> > field3=value3, ...) only works for the fields appears, but not for those 
> > absent. Is this a expected behavior or is it considered a bug? 
> > 
> > See example. 
> > 
> > # -*- coding: utf-8 -*- 
> > db.define_table('my_table', 
> >     Field('foo', requires=IS_NOT_EMPTY()), 
> >     Field('bar', requires=IS_NOT_EMPTY()), 
> > ) 
> > 
> > def index(): 
> >     # r = db.my_table.validate_and_insert(foo='hello', bar='world')  # 
> Pass. 
> > Of course 
> > 
> >     # r = db.my_table.validate_and_insert(foo='hello', bar=None)  # 
> Refused. 
> > As expected. 
> > 
> >     r = db.my_table.validate_and_insert(foo='hello')  # This one got 
> > PASSED?! 
> > 
> >     if r.id: 
> >         return {'message': 'Created #%d' % r.id} 
> >     else: 
> >         return {'message': 'err: %s' % r.errors} 
> > 
> > 
> > Problem can be reproduced on web2py 2.4.6 and 1.99.4 
> > 
> > Thanks in advance. 
> > 
> > -- 
> > 
> > --- 
> > 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 web2py+un...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to