The Field class accepts a function as default argument.

This should work (i did not test it, mind the actual lambda left side
arguments):

db.tablename.fieldname.default = lambda r: str(r.id) + "_more_text"

On Dec 2, 1:23 am, Matthew <[email protected]> wrote:
> Is it possible to define a default field value using lambda like the a
> Computed Field?http://web2py.com/book/default/chapter/06#Computed-Fields
>
> I want to name nodes using their own ID fields, e.g., "Node 1", "Node
> 2", etc. Can I do this with lambda and not rely on a separate counter
> field?
>
> Thanks,
> Matthew

Reply via email to