For now, I'm calling db.commit on my own ondelete function 

def my_ondelete_function(table, record_id):                             
    print "Deleting %s from %s" % (record_id, table)                       
     
    db(table[table._id.name]==record_id).delete()                           
    
    db.commit()

so technically same delete() gets called twice - first in my ondelete 
function (listed above) and then immediately in gluon/sqlhtml.py
I know it is wrong/incorrect, but seems to be working for me.

Waiting for suggestions/comments from the group.

-Mandar

On Thursday, September 13, 2012 11:46:09 PM UTC+5:30, Mandar Vaze wrote:
>
> I'm using version 2.0.7 and seeing the same problem. 
> I looked at the gluon/sqlhtml.py and it doesn't look like problem is 
> specific to custom query (Although I too have custom query passed to the 
> sqlform.grid)
>
>      elif deletable and len(request.args)>2 and 
> request.args[-3]=='delete':  
>          table = db[request.args[-2]]                                     
>    
>          if ondelete:                                                     
>    
>              ondelete(table,request.args[-1])                             
>    
>          ret = db(table[table._id.name]==request.args[-1]).delete()       
>    
>          db.commit() # If I add this, the record is deleted from DB too
>          return ret 
>
> I confirmed this by adding "db.commit()" just prior to returning. Without 
> this line, the record is removed from the table - but not form DB. So next 
> time we refresh and re-render the table, the deleted record re-appears
>
> BTW, I have another function for bulk_delete (User selects from checkbox, 
> and deleted selected records in one go) I am not calling db.commit() there 
> explicitly but the records are indeed deleted from DB.
>
> What is going on ?
>
> -Mandar
>
> On Tuesday, June 12, 2012 6:14:38 PM UTC+5:30, rahulserver wrote:
>>
>> I have the following sqlform.grid:
>> COMMITMENTS=SQLFORM.grid((db.Commitments.Account==session.id
>> ),user_signature=False)
>>
>> When I try to edit any row of the form, the edit is not committing. Is it 
>> that the sqlform.grid does not allow edits for query arguments?
>>
>

-- 



Reply via email to