[ZPT] creating lists of objects in tal
sinan at bccn-goettingen.de
Thu Sep 7 09:10:09 EDT 2006
in a page template (namely, in a portlet TAL script),
i am trying to create a list of ZOPE objects (from different
folders), sort them and display them in a convenient way.
the portion of the script that creates the list of objects is
<div tal:define="aboutbccn python:getattr(portal, portalitem);
<div tal:repeat="aboutbccnitems python:aboutbccn.contentIds()">
tal:condition="python:aboutbccnitems.find('press') == 0 or
aboutbccnitems.find('media') == 0">
tal:define="mr python:getattr(aboutbccn, aboutbccnitems)">
<div tal:repeat="obj python:mr.contentValues()">
<!-- HERE IS THE SLOWING PART: -->
<p tal:define="a python:announcements.append(obj)"
// AND SUFFICIENT NUMBER OF </div>s
the "announcements python:" part in tal:define tag initializes the
list, and the list becomes populated with the
"a python:announcements.append(obj)" in tal:define tag.
the problem is that the script works really slowly; the page takes at
least a few minutes to respond and display the outcome (i'm sure of
the fact that it is the "a python:announcements.append(obj)" part
that causes the slow-down). the python process on the server uses
%99 percent of the cpu after this script gets displayed on my page
and i have to restart zope to be able to get the webpage work normally
does anyone have an idea why python process goes crazy with this
template? another question is whether there is any problem with using
list of zope objects (i prefer to use lists over dictionaries because i
want to sort them and as far as i know dictionaries are not sortable).
for reference, the system i am using:
thank you in advance
More information about the ZPT