>
> import apt_pkg
> def important():
> apt_pkg.init()
> cache = apt_pkg.Cache()
> for pkg in cache.packages:
> if pkg.essential:
> return dict(t=pkg)
>
When you call "return" in Python, the function terminates, so this will
exit the loop after the first iteration.
> {{extend 'layout.html'}}
> <ul>
> <li>{{=t.name}}</li>{{pass}}
> </ul>
>
Views don't simply iterate automatically -- if you want to repeat some
elements in a loop, you have to write an explicit loop. Instead, maybe
something like:
def important():
[snip]
return dict(packages=[package.name for package in cache.packages if
package.essential])
View:
<ul>
{{for package in packages:}}
<li>{{=package}}</li>
{{pass}}
</ul>
or even easier:
{{=UL(packages)}}
Note, if you pass a list to the UL() helper, it automatically converts its
elements to LI's.
Anthony