I figured out what the problem is. in SQLFORM.grid
ret = db(table.id==request.args[-1]).delete()
if ondelete:
return ondelete(table,request.args[-1],ret)
the record is deleted before ondelete is called. This was for
conformity with the oncreate and onupdate. I had to think about this
one but it does make sense to call ondelete before the record is
actually deleted else the info is not available. I have changed the
behavior and your code should not work. Please give it a try.
On Nov 17, 2:45 am, Casey Schroeder <[email protected]> wrote:
> Thanks Massimo,
>
> I am trying this:
>
> delmem = lambda table, itid, ct:
> auth.del_membership(auth.id_group("auth_group_1"),
> table[int(itid)].userid)
>
> SQLFORM.grid(...ondelete=delmem...)
>
> table[int(itid)] however, is returning a none type, so the userid is
> inaccessible in this way. An exception is thrown and caught, and the
> db rolls back the delete (all in local SQLite).
>
> The _dict_ of the table appears empty and I have not been able to find
> where in the table the data is buried if at all. Running the relevant
> select itself returns nothing - i made the above mentioned change
> manually, but it appears the same as that in mercurial.
>
> Thanks
>
> On Nov 17, 7:52 am, Massimo Di Pierro <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > Hello Casey, Can you show us your test?
>
> > On Nov 16, 1:14 pm, Casey Schroeder <[email protected]> wrote:
>
> > > There may be an update on this that i missed, but can I ask if this
> > > fix is sufficient?
>
> > > I believe that the ret parameter is the effected row count, correct?
>
> > > If you just deleted the record, can you reliably retrieve it from the
> > > table and record id inondelete, i.e. before a subsequent commit? My
> > > *small* test say it doesn't work.
>
> > > Is there a way to get the record itself instead? Or am i missing this
> > > somewhere?
>
> > > Thanks
>
> > > On Oct 27, 6:46 pm, Massimo Di Pierro <[email protected]>
> > > wrote:
>
> > > > fixed
>
> > > > On Oct 26, 4:54 pm, Bob St John <[email protected]> wrote:
>
> > > > > using 1.99.2
>
> > > > > in gluon.sqlhtml.SQLFORM.grid:
>
> > > > > line 1489: returnondelete(table,request.args[-2],ret)
>
> > > > > I think it should be: returnondelete(table,request.args[-1],ret)
>
> > > > > As it is now,ondeletegets (table, table, ret), whereas I believe it
> > > > > should get (table, record_id, ret) to work properly...
>
> > > > > I like thisgridmethod!