Zope ZPT Output only unique items from a list

You can leverage ZPT global variables to output unique items from a list.

The subset of python methods available to Zope is limited, so using global variables is a workable way to create a list of unique items.
<tal:unique_loop define="global items_unique python: []" repeat="item items">
	<span tal:condition="python: item not in items_unique">
		<tal:append define="dummy python: items_unique.append(item)" />
		<tal:output content="item" />
	</span>
</tal:unique_loop>	
Posted by
Snippet Viewed 1472 times.

Share your Zope ZPT code snippets:

  • Get some recognition & link back to your site.

 

Submit | Browse

Most Recent zope zpt snippets

Most Viewed