[Zope] When is an empty list not an empty list?
John Schinnerer
john at eco-living.net
Sun Jun 18 04:20:21 EDT 2006
Aloha,
I have a python script, getCatalogItems(), which returns a (possibly
empty) list resulting from a catalog query. The lone parameter is the
sort index; the rest of the query is taken from the request. Anyhow...
If nothing was found, I don't want to display an empty table of results.
When I do this query and then check for empty list to see if the query
returned any items:
<div tal:define="items python:container.getCatalogItems('id')">
<table tal:condition="python: items!=[]">
...
...it doesn not work, that is, the (empty) table displays when items is
in fact an empty list.
If I do this instead:
<div tal:define="items python:container.getCatalogItems('id')">
<table tal:condition="python: len(items)>0">
...
...then the condition works, no empty table is displayed if the list is
empty.
Why does the former not work and the latter does?
I need to understand the difference in the python expressions...makes no
sense to me at present that they don't work the same.
thanks for any help,
John S.
--
John Schinnerer - MA, Whole Systems Design
------------------------------------------
- Eco-Living -
Whole Systems Design Services
People - Place - Learning - Integration
john at eco-living.net
http://eco-living.net
More information about the Zope
mailing list