【问题标题】:Using url_for triggers AttributeError: 'thread._local' object has no attribute 'mapper'使用 url_for 触发 AttributeError: 'thread._local' 对象没有属性 'mapper'
【发布时间】:2011-10-25 18:39:38
【问题描述】:

我正在尝试在带有金字塔的 mako 模板中使用 url_for(使用书籍示例):

${h.url_for(controller='formtest',action='submit')}

当我这样做时,我得到了这个错误:

AttributeError: 'thread._local' object has no attribute 'mapper' 

我安装了路由并将其放入我的 helpers.py 文件中:

import webhelpers.html.tags as tags
from routes import url_for

谷歌搜索错误,我读到 url_for 已被 Pylons 弃用。金字塔也是这样吗?如果是这样,我应该使用什么?

【问题讨论】:

    标签: python routes pyramid url-for


    【解决方案1】:

    您确定您使用的是 Pyramid 吗? 您发布的每一件事都是关于 Pylons 而不是 Pyramid。它们是非常不同的框架。

    假设您使用 Pylons,url_for 已被弃用。您应该改用从from pylons import url 导入的url 全局变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-15
      • 1970-01-01
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多