On Wednesday, December 19, 2012 3:24:31 PM UTC+5:30, Niphlod wrote:
>
> I can't reproduce the issue. 


I know it is a bit tough one. Even I too wasn't able to pinpoint the exact 
problem. I debugged till the dal.py as well. Not sure when does the 
db.commit() get called.
 

> Can you post a packed application showing the problem ? 


Can't. Anyway, I'm pasting some relevant code below. BTW, if it matters, I 
started the development with 2.0.x and upgrade just the web2py code to 
current stable release i.e. After I upgrade web2py I do not go by to my 
application and make any changes (like web2py.css or any other)

In a file under modules :

from gluon import current
import datetime

def modify_grid(grid, hide_adv_search=False,
        bootstrap_pagination=False, rename_view_btn=False,
        non_web2py_table=False):
    T = current.T
    if hide_adv_search:
        # Remove Advanced Query Slideout
        if len(grid.elements('input[id=web2py_keywords]')):
            grid.elements('input[id=web2py_keywords]')[0]['_onfocus'] = ""


    if bootstrap_pagination:
        if len(grid.elements('.web2py_paginator')):
            grid.elements('.web2py_paginator')[0]['_class'] = 'pagination'


    if non_web2py_table:
        if len(grid.elements('.web2py_table')):
            grid.elements('.web2py_table')[0]['_class'] = \
                    'table table-striped'


    if rename_view_btn:
        # Change from "View" to "Details"
        # When using Buttons
        for btn in grid.elements('span'):
            if btn['_title'] == "View":
                btn['_title'] = T('Details')
                for y in btn.elements():
                    y[0] = T("Details")


        # When NOT using Buttons
        for a in grid.elements('a[title=View]'):
            a.elements()[0]['_title'] = T('Details')



Following are in same file under controllers:

def delete_record(table, record_id):
    record = db(table[table._id.name] == record_id).select().first()
    if 'name' in record:
        print "User [%s] is Deleting [%s] from [%s]" % (auth.user.first_name
,
                                                        record['name'],table
)
    else:
        print "User [%s] is Deleting [%s] from [%s]" % (auth.user.first_name
,
                                                        record_id, table)
    db(table[table._id.name] == record_id).delete()
    db.commit()

@auth.requires_login()
@auth.requires_membership('some_role')
def my_method():
    textlengths = {'table.column1': 100, 'table.column2': 60,
                'table.column2': 60}
    grid = SQLFORM.grid(db.table, user_signature=False, csv=False,
           ondelete=delete_record,
           maxtextlengths=textlengths, showbuttontext=False)
    modify_grid(grid, hide_adv_search=True, bootstrap_pagination=True,
                rename_view_btn=True, non_web2py_table=True)

    return dict(grid=grid)

I hope this helps. As I mentioned in the bug report, the table has 
"db.table.id.readble=False" in models. But that conclusively did not tell 
me anything. But might help you.

-Mandar

-- 



Reply via email to