What if you do:

SQLFORM.smartgrid(..., oncreate=crud.archive, onupdate=crud.archive)

or

SQLFORM.smartgrid(..., onupdate=lambda form: crud.archive(form, 
archive_current=False))

Note, archive_current=False tells it to archive the previous record (the 
one being updated) rather than the current record (the updated version).

Anthony

On Tuesday, December 27, 2011 10:54:35 AM UTC-5, Cliff wrote:
>
> This also works SQLFORM.smartgrid(..., onvalidation=crud.archive... 
>
> But, I now discover archive never saves the original record.  You can 
> edit the record and it saves the edits, but it never gets the first 
> version of it. 
>
> This statement from the Official Book"on updating, it stores a copy of 
> the record (as it was before the update)" is incorrect, at least as 
> far as smartgrid is concerned.  I haven't tried it with SQLFORM by 
> itself or with CRUD. 
>
> On Dec 27, 9:38 am, Anthony <abas...@gmail.com> wrote: 
> > Have you tried: 
> > 
> > form = SQLFORM.smartgrid(..., onupdate=auth.archive) 
> > 
> > Also, note there is also crud.archive, which is the same as 
> auth.archive. 
> > 
> > Anthony 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Tuesday, December 27, 2011 7:22:34 AM UTC-5, Cliff wrote: 
> > 
> > > This is some ugly code that makes auth.archive() work with smartgrid: 
> > 
> > > if len(request.args) > 3 and request.args[-4] == 'owner' and\ 
> > >        request.args[-3] == 'edit' and request.args[-2]=='owner'\ 
> > >        and form[2].process(onsuccess=auth.archive).accepted: 
> > >         pass 
> > 
> > > Surely there must be a better way.  Any and all hints gratefully 
> > > accepted.

Reply via email to