This is a syntactical issue: 1) the functio must take form as arguement
def deletepage(form): decrements total number of pages decrements page number of each page after the one deleted 2) when registering the callback no () crud.settings.update_ondelete = deletepage On Nov 19, 9:09 am, Audra Rudys <sphin...@gmail.com> wrote: > My application follows a book metaphor -- record with number of pages and > subrecords with consecutive page numbers. I'm using crud.update and wish to > run a piece of code to update the total number of pages on the record and > reassign page numbers when a record is deleted to keep them consecutive. I > created a function deletepage() to do this and set update_ondelete to call > it. I'm also using update_next. > crud.settings.update_next = URL(...) > crud.settings.update_ondelete = deletepage() > > fun deletepage(): > decrements total number of pages > decrements page number of each page after the one deleted > > The problem: update_ondelete is being called whenever edit is invoked, > regardless of whether a record has been deleted. So, if I click edit to > edit the record, make no changes and go back with the browser back button, > deletepage() was called once. If I click edit and then submit the form, > regardless of any changes or whether or not I've selected to delete the > record, deletepage() is called twice. > > 1) Is this a web2py bug with ondelete or am I not using it correctly? > 2) Is there a way to check if a record has been deleted? > 3) At which point in the workflow is is actually deleted from the database? > (I tried querying the subrecord count in ondelete to get the new page count > instead of blindly decrementing, but the deleted record was still counted.) > > Environment info: web2py 1.89.3 and 1.89.4 source on WinXP (from version > file within, both look to be 1.89.3 though), Chrome browser 7.0.517.44. > > Thanks for any help! > Audra