Here’s a quick post based on a Python Script I made in Zope to display the data from a ZSQL method in a 2 column table layout. Not that big of a deal, but I wanted to save this because it took a little bit of thought and some learning.
(My original code is all mess up on this, I’ll try to find and repost it.)
## Script (Python) "genlodinfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=itemid ##title= ## # Example code: ################################### """ Author: Greg Fischer 1st Byte Solutions - greg@1stbyte.com Date: 9/24/05 License: You are free to reengineer rework, recode, redistribute, resell or alter this code in any way you see fit, but you must give credit to my original work and you must provide this same license to those that may receive your distribution if you do. (just leave my name on it, and you must offer the same freedom in your work, that's all) Purpose: This script will gather from a zsql method, cat the records into address records (with exra info), then generate a table with alternating rows. In other words, it will fill the table from left to right, then down a row, 2 columns wide. """ ################################### def iseven(n): """Return true if n is even.""" return n%2==0 def isodd(n): """Return true if n is odd.""" return not iseven(n) # Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE rs = context.sql.ap_lodging(itemid) rownum = 1 x = [] for r in rs: ritemid = str(r[0]) rtqstart = str(r[4]) rtqend = str(r[5]) rstreet1 = r[12] rstreet2 = r[13] rcity = r[14] rstate = r[15] rzip = r[16] rnotes = r[18] lodstr = rtqstart + ' - ' + rtqend + ' ' lodstr = lodstr + rstreet1 + ' ' + rstreet2 + ' ' lodstr = lodstr + rcity + ', ' + rstate + ' ' + rzip + ' ' if rnotes <> '': lodstr = lodstr + rnotes + ' ' x.append(lodstr) table = '' tablee = '
And you return the results simply by calling the script in your dtml. something like: dtml-var “path.to.script(itemid=itemid)”
As always, I hope this help someone else out there, not just myself! Good luck!