I do not want to add methods to Row object for various reasons including performance. moreover we have a feature freeze until we address some more important issues with dal.py.
On Wednesday, 2 April 2014 20:23:50 UTC-5, Matt wrote: > > Thanks. Yes that's true. > > However I do think there are definitely situations where it would be > useful to be able to call validate like this arbitrarily. > > On Thursday, April 3, 2014 2:01:17 PM UTC+13, Massimo Di Pierro wrote: >> >> You can do >> >> errors = db(db.client.id==client.id).validate_and_update_(**vars) >> >> >> >> On Wednesday, 2 April 2014 19:03:49 UTC-5, Matt wrote: >>> >>> Also adding support for >>> >>> errors = client.validate_and_update_record(**vars) >>> >>> would be useful too. >>> >>> On Thursday, April 3, 2014 12:30:55 PM UTC+13, Matt wrote: >>>> >>>> How do I achieve the following elegantly with Web2py? >>>> >>>> Before I update an in memory record I want to check it's validators to >>>> make sure it makes sense before I actually update. >>>> >>>> I.e. >>>> >>>> client = db.client(7) >>>> >>>> if not client: >>>> raise HTTP(404) >>>> >>>> errors = client.validate(**vars) <== Something like this. >>>> >>>> if errors: >>>> raise HTTP(422) >>>> >>>> client.update_record(**vars) >>>> >>>> >>>> Is that something that's possible with the current framework or could >>>> we have it added as it would be extremely useful. >>>> >>>> I noticed there seems to be a private def _validate in the dal that >>>> could be exposed for this purpose. >>>> >>>> Interested to hear your thoughts. >>>> >>>> Thanks in advance, >>>> Matt >>>> >>>> >>>> -- 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.