[Zope-DB] Testing for empty result set
chris at simplistix.co.uk
Sat Mar 26 05:40:46 EST 2005
Dieter Maurer wrote:
> Charlie Clark wrote at 2005-3-24 13:44 +0100:
>>your right tal:condition is what you should be using. However, as
>>Results-Objects with empty records are not None you still need a little
>>Python test to get things to work correctly.
>><div tal:condition="python: len(context.myZSQL())">
> While an empty result set is not "None", it behaves as a
> Python "false" value.
> Therefore, you can (and should) use
However, both of these may lead an inxpereinced person to call their
ZSQL method twice for each page rendering.
I'd suggest doing something like:
<table tal:define="results context/myZSQL">
No results were found.
<tr tal:repeat="result results">
Simplistix - Content Management, Zope & Python Consulting
More information about the Zope-DB