Zope DTML Advanced ZSQL example

Demonstrates using dtml loops and let blocks in the context of a zsql method.
SELECT f.attribute_name
FROM attribute f
LEFT JOIN attribute_pc_xref apx
	ON apx.attribute_id = f.attribute_id
LEFT JOIN product_category pc
	ON pc.pc_id = apx.pc_id
WHERE f.listable = 1
<dtml-in criteria>
	<dtml-let num=sequence-item>
	AND (SELECT Count(1) FROM attribute_pc_xref WHERE attribute_id = <dtml-sqlvar expr="num.split('=')[0]" type="int"> AND 
		 attribute_value LIKE CONCAT('%', <dtml-sqlvar expr="num.split('=')[1]" type="string">, '%') AND pc_id = pc.pc_id) = 1
GROUP BY f.attribute_name
Posted by
Snippet Viewed 2712 times.

Share your Zope DTML code snippets:

  • Get some recognition & link back to your site.


Submit | Browse

Most Recent zope dtml snippets

Most Viewed