[web2py] Re: Precise behaviour of "compute" on record update

2010-11-19 Thread cjrh
On Nov 18, 3:05 pm, cjrh wrote: > "I have a field that is a uuid which is > only supposed to be calculated once, on insertion." > > Best way to do this currently?  I would use "default" if within the > context of a controller, but these are records I create manually in > admin.  There is a field t

[web2py] Re: Precise behaviour of "compute" on record update

2010-11-18 Thread cjrh
On Nov 18, 3:46 pm, mdipierro wrote: > >>> db=DAL() > >>> db.define_table('xxx',Field('yyy',writable=False,readable=False)) > >>> db.xxx.yyy.default=lambda: 'hello world' > >>> db.xxx.insert() > 1 > >>> print db.xxx(1).yyy > > hello world > > default can be a lambda. If I do this inside db.py, th

[web2py] Re: Precise behaviour of "compute" on record update

2010-11-18 Thread cjrh
On Nov 18, 3:46 pm, mdipierro wrote: > >>> db=DAL() > >>> db.define_table('xxx',Field('yyy',writable=False,readable=False)) > >>> db.xxx.yyy.default=lambda: 'hello world' > >>> db.xxx.insert() > 1 > >>> print db.xxx(1).yyy > > hello world > > default can be a lambda. I did not know that. I'm goi

[web2py] Re: Precise behaviour of "compute" on record update

2010-11-18 Thread mdipierro
>>> db=DAL() >>> db.define_table('xxx',Field('yyy',writable=False,readable=False)) >>> db.xxx.yyy.default=lambda: 'hello world' >>> db.xxx.insert() 1 >>> print db.xxx(1).yyy hello world default can be a lambda. On Nov 18, 7:05 am, cjrh wrote: > "I have a field that is a uuid which is > only sup

[web2py] Re: Precise behaviour of "compute" on record update

2010-11-18 Thread cjrh
"I have a field that is a uuid which is only supposed to be calculated once, on insertion." Best way to do this currently? I would use "default" if within the context of a controller, but these are records I create manually in admin. There is a field that I want populated with a newly-calculated

[web2py] Re: Precise behaviour of "compute" on record update

2010-11-18 Thread mdipierro
true. the text should be fixed. On Nov 18, 1:46 am, cjrh wrote: > Regarding the "compute" attribute of a Field object, the book says > this: > > "compute is an optional function. If a record is inserted and there is > no value for a field that has a compute attribute, the value is > calculated by