Thanks guys,
After all your comments I have found the problem: my agent database was
defined *twice* in my models, one time with computed fields, the final time
without them. I was getting very strange behavior and was quite confused -
understandably.
I have removed the phoney definition, and now the computed fields are
filled-in as expected.
And now a small explanation of why I did not notice this at first:
I had a define_table in a testing.py controller. I have removed this
controller from my development repo, but since I am rsyncing to the web2py
applications directory, that old testing.py controller was still in the
testing environment. Since web2py is loading all controllers, the agent
table was being defined twice, without me noticing it.
The root problem is that I can not by default rsync to the test environment
*deleting* files, since the databases are also in the application directory
structure.
How are you guys solving these problems? Are you putting the databases
(sqlite in this case) outside of the application directory?
Thanks,
Daniel
On Wednesday, August 22, 2012 4:46:46 PM UTC+2, Anthony wrote:
>
>
>>>
>>> Field('password', 'password', length=512, compute=automatic_password
>>> , readable=False, label='Password'),
>>>
>>> The functions create_new_agent and automatic_password are part of my
>>> libraries. They are returning the expected types (strings in both cases)
>>>
>>
>> If you search the book for 'computed field' you will see that you need to
>> use lambda in this case.
>>
>> Try
>>
>> Field('password', 'password', length=512, compute=lambda r:
>> automatic_password(), readable=False, label='Password')
>>
>
> If automatic_password takes a single required argument (i.e., the Row
> object), then compute doesn't have to be a lambda -- you can use
> automatic_password directly. It just depends on the signature of
> automatic_password.
>
> Anthony
>
--