为Z SQL方法设置变量 [英] Setting a variable for a Z SQL method
问题描述
在Plone中,我有一个Z SQL方法:
In Plone I have a Z SQL methood:
SELECT [aapp_qtitle]
,[aapp_mtitle]
,[aapp_sdate]
,[aapp_duration]
FROM [AAPP].[dbo].[M_PageBodyElement] where [aapp_id]=<dtml-sqlvar aapp_id type=int>
如何在我的Plone页面代码中设置aapp_id的值?
How can I set the value of aapp_id in my Plone page code?
好的,谢谢Matthew,确切的模板代码是什么?我尝试过:
OK thanks Matthew what's the exact template code? I've tried:
<p tal:define="AAPPInfo python:here.get/AAPPInfo(aapp_id=100003).dictionaries()"></p>
<p tal:repeat="records context/AAPPInfo">
<span tal:replace="records/aapp_qtitle">Title: </span><br>
但是我得到名称'AAPPInfo'的定义错误.
But I get name 'AAPPInfo' is not defined error.
推荐答案
例如,如果ZSQL方法被称为"getAAPPInfo",则可以从Python中这样调用它:
If the ZSQL method was called 'getAAPPInfo', for example, you would call it from Python like this:
AAPPInfo = context.getAAPPInfo(aapp_id=1).dictionaries()
if AAPPInfo:
print AAPPInfo[0]['aapp_qtitle']
或类似的
在页面模板中,您需要使用表达式tal:define="AAPPInfo python:here.getAAPPInfo(aapp_id=1).dictionaries()
,然后您可以照常遍历该表达式.
From a Page Template you need to use the expression tal:define="AAPPInfo python:here.getAAPPInfo(aapp_id=1).dictionaries()
and then you can iterate through that as normal.
这篇关于为Z SQL方法设置变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!