web2py SQLFORM.grid url

web2py SQLFORM.grid url,grid,web2py,Grid,Web2py,当我尝试将form=SQLFORM.grid(db.mytable)放入控制器时,请求更改为my/web/site/view?_signature=520af19b1095db04dda2f1b6cbea3a03c3551e13,这会导致控制器中的if语句崩溃。smbd能否解释为什么会发生这种情况 如果我将user_signature=False,则在视图加载时会显示网格(尽管外观很糟糕,我仍然需要了解如何更改我的表的视图),但在搜索、编辑等操作时,再次出现相同的情况。url已更改,我收到一个错

当我尝试将form=SQLFORM.grid(db.mytable)放入控制器时,请求更改为my/web/site/view?_signature=520af19b1095db04dda2f1b6cbea3a03c3551e13,这会导致控制器中的if语句崩溃。smbd能否解释为什么会发生这种情况

如果我将user_signature=False,则在视图加载时会显示网格(尽管外观很糟糕,我仍然需要了解如何更改我的表的视图),但在搜索、编辑等操作时,再次出现相同的情况。url已更改,我收到一个错误

有什么建议吗

多谢各位

编辑

这是我的编辑功能

@auth.requires_login()
def edit():
    #Load workers
     workers = db(db.worker.w_organisation == 10).select(db.worker.w_id_w, db.worker.w_organisation, db.worker.w_first_name, db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,db.worker.w_status,db.worker.w_note).as_list()


#Define the query object. Here we are pulling all contacts having date of birth less than 18 Nov 1990
query = ((db.worker.w_organisation == 10) & (db.worker.w_status==db.status.s_id_s))

#Define the fields to show on grid. Note: (you need to specify id field in fields section in 1.99.2
fields = (db.worker.w_first_name, db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,db.status.s_code,db.worker.w_note)

#Define headers as tuples/dictionaries
headers = { 'worker.w_first_name' :   'Ime',
       'worker.w_last_name' : 'Priimek',
       'worker.w_nick_name' : 'Vzdevek',
       'worker.w_email' : 'E-posta',
       'status.s_code': 'Status',
       'worker.w_note' : 'Komentar' }

#Let's specify a default sort order on date_of_birth column in grid
default_sort_order=[db.worker.w_last_name]

#Creating the grid object
form = SQLFORM.grid(query=query, fields=fields, headers=headers,searchable=True, orderby=default_sort_order,create=True, \
                deletable=True, editable=True, maxtextlength=64, paginate=25,user_signature=False
                )

form = SQLFORM.grid(db.worker,user_signature=False)


workersDb = db((db.worker.w_organisation == 10) & (db.worker.w_status==db.status.s_id_s)).select(db.worker.w_id_w, \
                                                db.worker.w_organisation, db.worker.w_first_name, \
                                                db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,\
                                                db.status.s_code,db.worker.w_note).as_list()

workersList = []


for rec in workersDb:
    status =  rec['status']['s_code']
    workers = rec['worker']

    if not rec["worker"]["w_first_name"]:
        polno_ime = rec["worker"]["w_last_name"]
    elif not rec["worker"]["w_last_name"]:
        polno_ime = rec["worker"]["w_first_name"]
    else:
        polno_ime = rec["worker"]["w_first_name"] + " " + rec["worker"]["w_last_name"] 
    rec["worker"]['w_full_name'] = polno_ime
    rec["worker"]["w_status"] = status
    data = rec["worker"]
    #print rec
    #print data
    workersList.append(rec["worker"])

# If type of arg is int, we know that user wants to edit a script with an id of the argument
if(request.args[0].isdigit()):
    script = db(getDbScript(request.args[0])).select(db.script.sc_lls, db.script.sc_name, db.script.id, db.script.sc_menu_data).first()
    formData = str(script["sc_menu_data"])
    #form = SQLFORM.grid(db.auth_user)
    #print formData
    # If we dont get any results that means that user is not giving proper request and we show him error
    #print script
    #Parsing script to be inserted into view

    if not script:      
        return error(0)
    return dict(newScript = False, script = script, formData = formData, workers = workersList, form = form)
# If the argument is new we prepare page for new script
elif request.args[0] == 'new':
    scripts = db((auth.user.organization == db.script.sc_organization)).select(db.script.sc_name, db.script.id, workers = workersList, form = form)

    return dict(newScript = True, scripts = scripts, workers = workersList, form = form)
# Else error
else:
    return error(0)

更不用说sqlgrid看起来很糟糕,下面是图片的链接

如果您显示
if
语句,我们可以找出如何更正它。签名是出于安全目的而存在的,因此URL不能被操纵。请澄清您的期望和正在发生的情况(例如,您是否遇到异常?)。您的
if
语句检查request.args[0]的值,因此用户签名将不受影响(因为它存储在request.get\u vars中)。此外,URL看起来不像my/web/site/view?\u签名=。。。相反,它将类似于/yourapp/default/edit/view/worker/1?\u signature=。。。(最后,请在上面的代码中添加换行符,这样我们就不必水平滚动。)另外,为什么要将
.as_list
方法应用于
对象,而不是使用正常的
功能来访问记录和字段?关于网格的外观,您是否使用带有默认CSS的脚手架应用程序,您能否确认CSS文件已加载到该页面上?如果没有,您将需要应用自己的CSS样式。