uhm.... I always seen that as a simple thing. context is equal to the dict you normally return from the view.
On Monday, August 20, 2012 11:17:23 PM UTC+2, Yarin wrote: > > Im trying to follow the example given > here<https://groups.google.com/forum/?fromgroups=#%21topic/web2py/yBBhvADGGB4%5B1-25%5D>for > manually rendering views. > > I have this code in my controller: > > def index(): > > global my_var > my_var = "something" > content = '''<html><body><h1>My Page</h1><p> > {{=my_var}} > {{=request.raw_args}} > </body></html>''' > > output = render(content,context=dict(n=5)) > return output > > > but this won't work- it gives an error: > >> <type 'exceptions.NameError'> name 'my_var' is not defined > > > Questions: > > - How do I create variables in the controller that can then be > referenced in the rendered view? > - Can I access global vars like request/response in the rendered view? > - what does the context dictionary do? > > (I tried but couldn't make sense of the render function in template.py. > I'm clueless to the scoping consequences of this stuff...) > > > --

