First, note that you are not limited to using a lambda -- you can use any function/callable. So, if you need to do an assignment, write a separate function.
In this case, though, you can instead use the .update method: db.solicitacao._before_update.append(lambda qset, f: f.update(cadastro=request.now if f['status'] in ['Edição', 'Enviado'] else None)) Also, note that the first argument passed to the callback is the set object, not the fields; and the fields object is a dictionary, so you have to do f['status'] rather than f.status. Anthony On Thursday, June 12, 2014 2:54:03 PM UTC-4, Fabiano Almeida wrote: > > Hi, > > In a table I need to change the field value (name: cadastro, type: > datetime) to request.now depending on the value assigned to another field > (name: status) of the same record. > > I thought of using the _before_update callbcak for this purpose: > > db.solicitacao._before_update.append(lambda f: f.cadastro=request.now if > (f.status == 'Edição') or (f.status =='Enviado') else None) > > Thus returns the message "*lambda cannot contain assignment*" > > Any suggestions? > > Thanks in advance, > > Fabiano. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.