>
> <h4><i class="icon-user"></i> me (from sidebar.html):</h4>
{{query=db.about.id>0}}
> {{ab=db(query).select()}}
> {{dict(ab=ab)}}
>
The dict line above isn't necessary. The controller function returns a dict
so that the dict's keys will be added as global variables in the view
environment, but since you're already in the view here, simply defining the
ab variable is sufficient.
> {{for pre in ab:}}
>
Actually, you might as well just do this:
{{for pre in db(db.about).select():}}
> but it would have been better to return the ab dict from the sidebar.py
> controller instead.
>
If you really want the sidebar created by its own controller function and
view, you can use a component (i.e., the LOAD helper), though in this case
that would probably generate an unnecessary amount of extra processing for
something rather simple. If you don't want to run the query in the view but
need the sidebar on every page, then you can simply define the ab variable
in a model file (all variables defined in model files are available
globally in all views).
It might also be a good idea to cache the query for some amount of time to
avoid a separate database hit on every page request.
Anthony
--