I am attempting to use url_for inside of a mako template with pyramid (using a book example):
${h.url_for(controller='formtest',action='submit')}
When I do, I get this error:
AttributeError: 'thread._local' object has no attribute 'mapper'
I installed routes and put this in my helpers.py file:
import webhelpers.html.tags as tags
from routes import url_for
Googling the error, I read that url_for has been deprecated for Pylons. Is this true for Pyramid too? If so, what should I be using?
Are you sure you’re using Pyramid? Every thing that you have posted is about Pylons and not Pyramid. They are very different frameworks.
Assuming you are using Pylons,
url_forwas deprecated. You should instead be using theurlglobal variable which is imported fromfrom pylons import url.