【发布时间】:2015-03-15 21:38:50
【问题描述】:
我一直在使用 web2py 开发应用程序。我有一个带有回调链接的页面,该链接将信息发送到另一个函数,这会通过页面右侧边栏中的 ajax 加载结果。单击链接时,链接本身会消失,但结果会正确加载。我必须刷新页面才能返回链接。我已经看这个很久了,但无法弄清楚,我对 web2py 比较陌生,所以可能错过了一些明显的东西。 这是一些代码:
视图(带链接):
{{if hosts == "Please select a category":}}
{{response.write("Please select a category")}}
{{else:}}
<ol>
{{for i in hosts:}}
<li>{{=A(i['HostName'], callback=URL('selection','getResults.load', vars=dict(clicked=i['HostName'])), target="monitoredDevice")}}</li>
{{pass}}
</ol>
{{pass}}
{{end}}
{{block right_sidebar}}
<div id="monitoredDevice">
</div>
{{end}}
控制器动作:
def getResults():
hostName = request.vars.clicked
# hostName = request.vars.hostNameSelected
print(hostName)
try:
task_status = scheduler.task_status(db.scheduler_task.task_name==hostName, output=True)
result = task_status.result
# create_compare_graph()
except(AttributeError): # Error is because there is no scheduler and therefore no status, need to set the values to 0
result = emptyTaskStatusResultsToZero()
try:
return dict(result)
except(TypeError): # There is a task scheduled however there is no run data as it has not been run before. Causes an error.
return emptyTaskStatusResultsToZero()
我认为视图中的 =A 链接有问题?
谢谢!
【问题讨论】:
-
你能提供更多关于
emptyTaskStatusResultsToZero的细节吗?