My url builder requires the « id » field so _before_insert wouldn’t work.
That’s a good suggestion though! Thanks Anthony :) > Le 10 mars 2015 à 18:00, Anthony <abasta...@gmail.com> a écrit : > > Might be easier with a _before_insert callback, so you can add the new value > along with the initial insert instead of after: > > db.mytable._before_insert.append(lambda fields: > fields.update(url=make_url(fields))) > > Anthony > > On Tuesday, March 10, 2015 at 12:10:12 PM UTC-4, Niphlod wrote: > code an _after_insert callback. > > On Tuesday, March 10, 2015 at 4:21:26 PM UTC+1, Louis Amon wrote: > I'm trying to hard-code URLs for SEO purposes so I have a function > ("make_url(row)") that builds the paths based on other fields. > > I was thinking of using "compute=make_url", but it seems that update > operations also call the compute. > > > Is there a way to use compute only on INSERT operations, and not on UPDATE ? > > -- > Resources: > - http://web2py.com <http://web2py.com/> > - http://web2py.com/book <http://web2py.com/book> (Documentation) > - http://github.com/web2py/web2py <http://github.com/web2py/web2py> (Source > code) > - https://code.google.com/p/web2py/issues/list > <https://code.google.com/p/web2py/issues/list> (Report Issues) > --- > You received this message because you are subscribed to a topic in the Google > Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/I1acweQhAEY/unsubscribe > <https://groups.google.com/d/topic/web2py/I1acweQhAEY/unsubscribe>. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com > <mailto:web2py+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- 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.