How can I use modules in views?
For example I'm trying to use the markdown
module, so I import it into my controller:
from gluon.contrib.markdown.markdown2 import markdown
and I use response.render
return response.render('default/main.html', locals())
but when I try to access it in a view,
{{=markdown(post.message)}}
I get an error saying that it is not defined:
<type 'exceptions.NameError'> name 'markdown' is not defined
How can I pass module to views? Is there an alternative to the locals()
function to get it done?
On a side note, I can access db
and session
from my views, is this because they are imported in my models
?
Web2Py Version 1.99.7 (2012-03-04 22:12:08) stable
UPDATE: Importing it in my model db.py
seems to fix it. Is there a better way to do this?