Massimo, good news to me.

It shoud be in the book!



On Fri, Jan 28, 2011 at 12:32 PM, Massimo Di Pierro
<massimo.dipie...@gmail.com> wrote:
> The fact is, you can do both. If you want the values to be evaluated
> on insert, just do
>
> Field(...,default=lambda: f())
>
> instead of
>
> Field(...,default=f())
>
> If you want lazy evaluation you have to be explicit.
>
> On Jan 27, 4:51 pm, Vinicius Assef <vinicius...@gmail.com> wrote:
>> On Thu, Jan 27, 2011 at 3:54 PM, Bernd Rothert <roth...@googlemail.com> 
>> wrote:
>>
>> > Multiple inserts for the same request should get unique uuids of
>> > course, so we need a function here.
>>
>> I faced this problem some time ago.
>>
>> Default values defined in models are not assigned in INSERT time, but
>> in REQUEST time.
>>
>> So, if you have a loop with insert inside it, all records will have
>> the same default values.
>>
>> This is a web2py feature, in spite my thought explained that time that
>> it should be different. When you talk about database, default values
>> should be evaluated as in SQL INSERT: in insert time.
>>
>> --
>> Vinicius Assef.

Reply via email to