Have you looked into using components and LOAD:
http://web2py.com/book/default/chapter/13#Components?
Anthony
On Saturday, March 19, 2011 11:13:17 AM UTC-4, Hybride wrote:
> Hi everyone,
>
> I've been trying to include a separate page with database code into
> the layout to no avail. The reason for this is am trying to deploy the
> application on GAE, and without actually putting the code in a
> controller, GAE throws a fit on me. A regular database query works
> fine for the un-GAE version. My setup is:
>
> /controllers/default.py:
> def sidebar_latest():
> return
> dict(latest=db(db.t_problems.id>0).select(orderby=~db.t_problems.created_on,limitby=(0,5)))
>
>
>
> /default/sidebar_latest.html:
> {{include}}
> {{for l in latest:
> =LI(A(l.f_name, _href='/app/default/
> problems_read/'+str(l.id)))
> pass
> }}
> (Since I need it in the layout, I removed the extend/layout.html at
> the top; I still see the proper results)
>
> ( layout.html includes web2py_ajax.html, default/sidebar_latest.html)
> /views/layout.html:
> <div id="sidebar">
> <ul><li>
> <h2>Latest Problems</h2>
> <ul>
> {{include 'default/sidebar_latest.html'}}
> </ul>
> </li></ul>
> </div>
>
> I receive the error that "latest" is not defined. I do need the
> controller to show up on every single page of the site, that's why am
> trying to include it as such. Obviously, it's failing. If anyone has
> an idea how to fix it, would be greatly appreciated!