On Mon, May 30, 2011 at 5:46 PM, Flack <[email protected]> wrote:
> Not sure why you would want to avoid dictionary objects, but it's
> actually simpler imo to pass objects to mako in Pyramid. I believe
> you want something like:
>
> -- users.py --
> @view_config(renderer='users.mako)'
> def index(self):
> users = session.query(User).all()
> return {'users': users}
You *can* also use 'c' in Pyramid.
from pyramid.renderers import render_to_response
@view_config
def index(self):
c = self.request.tmpl_context
c.users = users
return render_to_response("users.mako", {}, self.request)
But the default way is better for unit tests because you can test the
return dict directly rather than parsing the HTML.
--
Mike Orr <[email protected]>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.