pylons 1.0 AttributeError: 'ContextObj' object has no attribute "xxx"

本文介绍如何解决从旧版本升级到Pylons1.0后出现的AttributeError异常问题,主要针对tmpl_context不再默认为AttribSafeContextObj的变化进行配置调整。

将代码升级至pylons1.0,原本运行良好的程序报出:
AttributeError: 'ContextObj' object has no attribute 'tabs' 异常,经过查询资料得知是pylons1.0相比较0.97做了一些调整,pylons 1.0默认情况下tmpl_context将不再是AttribSafeContextObj,也就是说:访问不存在的属性将产生AttributeError异常,为使用attribute-safe tmpl_context,可以更改config/environment.py,增加config['pylons.strict_tmpl_context'] = False即可.
官方说法原文为:
By default, the tmpl_context (a.k.a ‘c’), is no longer a AttribSafeContextObj. This means accessing attributes that don’t exist will raise an AttributeError.
    To use the attribute-safe tmpl_context, add this line to the config/environment.py:
    config['pylons.strict_tmpl_context'] = False

详情请参阅 http://pylonshq.com/docs/en/1.0/upgrading/

转载于:https://www.cnblogs.com/Jerryshome/archive/2011/04/17/2018778.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值