On 23 Aug 2012, at 7:25 AM, Massimo Di Pierro <massimo.dipie...@gmail.com> 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) --