tags:

views:

78

answers:

2

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>

How can I set the value of aapp_id in my Plone page code?

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>

But I get name 'AAPPInfo' is not defined error.

A: 

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']

or similar.

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.

Matthew Wilkes
A: 

AAPPInfo was a guess at what you called your SQL method. You also have ignored my syntax and written your own, that's why it's not working.

Matthew Wilkes
The SQL method is called AAPPInfo, so that's OK. If I put in <tal:define="AAPPInfo python:here.getAAPPInfo(aapp_id=1).dictionaries()> I get a compilation failed EOF in middle of construct...
Nathan Friend
http://plone.293351.n2.nabble.com/Z-SQL-methods-with-explicit-arguments-in-ZTP-tp5138564p5138564.html
Nathan Friend