Exactly. 

    mytable.myfield.set_attributes(readable=True,writable=True)

is just a shortcut for

   mytable.myfield.readable=True
   mytable.myfield.writable=True

without it the lambda notation would not be very usable.

On Saturday, 25 August 2012 11:50:10 UTC-5, Jonathan Lundell wrote:
>
> On 23 Aug 2012, at 7:25 AM, Massimo Di Pierro 
> <massimo....@gmail.com<javascript:>> 
> wrote: 
> > So now in trunk you can do: 
> > 
> > db = DAL(lazy_tables=True) 
> > db.define_table('person',Field('name'),Field('age','integer'), 
> >    on_define=lambda table: [ 
> >           
>  table.name.set_attributes(requires=IS_NOT_EMPTY(),default=''), 
> >           
>  table.age.set_attributes(requires=IS_INT_IN_RANGE(0,120),default=30), 
> >   ]) 
> > 
> > and the attributes will be set lazily. This is a good idea! Thanks 
> Jonathan. 
> > 
>
> Clear something up for me, please. I was a little confused before about 
> how this was implemented, but I've read the code and it looks like what I 
> proposed. What I'm not following is the role of set_attributes. Is it 
> simply to facilitate the lambda? Is this equivalent? 
>
> def on_define(table): 
>      table.name.requires = IS_NOT_EMPTY() 
>      table.name.default = '' 
>      table.age.requires = IS_INT_IN_RANGE(0,120) 
>      table.age.default = 30 
>
> db = DAL(lazy_tables=True) 
> db.define_table('person', Field('name'), Field('age','integer'), 
> on_define=on_define) 
>

-- 



Reply via email to