重氮,参数和restrictedTraverse

时间:2012-06-22 18:16:51

标签: plone diazo

如果在我的重氮控制面板中> '参数表达式'我把

have_left_portlets = python:context and context.restrictedTraverse('@@plone').have_portlets('plone.leftcolumn',context)

只有当我在门户网站主页上时才会收到错误:

2012-06-26 16:51:42 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
  File "/Users/vito/.buildout/eggs/plone.transformchain-1.0.2-py2.6.egg/plone/transformchain/transformer.py", line 48, in __call__
    newResult = handler.transformIterable(result, encoding)
  File "/Users/vito/.buildout/eggs/plone.app.theming-1.0-py2.6.egg/plone/app/theming/transform.py", line 257, in transformIterable
    params[name] = quote_param(expression(expressionContext))
  File "/Users/vito/.buildout/eggs/Zope2-2.13.13-py2.6.egg/Products/PageTemplates/ZRPythonExpr.py", line 48, in __call__
    return eval(self._code, vars, {})
  File "PythonExpr", line 1, in <expression>
  File "/Users/vito/.buildout/eggs/AccessControl-2.13.7-py2.6-macosx-10.6-x86_64.egg/AccessControl/ImplPython.py", line 675, in guarded_getattr
    v = getattr(inst, name)
AttributeError: 'FilesystemResourceDirectory' object has no attribute 'restrictedTraverse'

我如何解决这个问题?

2 个答案:

答案 0 :(得分:3)

我怀疑这是plone.app.theming中的一个错误:上下文设置不正确。但很奇怪。

答案 1 :(得分:1)

只是确认问题退出: 我得到了相同的回溯,网站本身看起来很好,但是对于网站内的每次点击,我在我的实例中获得了以下回溯fg:

2012-08-10 15:05:05 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
  File "/opt/etc/buildout/eggs/plone.transformchain-1.0.2-py2.6.egg/plone/transformchain/transformer.py", line 48, in __call__
    newResult = handler.transformIterable(result, encoding)
  File "/opt/etc/buildout/eggs/plone.app.theming-1.0-py2.6.egg/plone/app/theming/transform.py", line 257, in transformIterable
    params[name] = quote_param(expression(expressionContext))
  File "/opt/etc/buildout/eggs/Zope2-2.13.10-py2.6.egg/Products/PageTemplates/ZRPythonExpr.py", line 48, in __call__
    return eval(self._code, vars, {})
  File "PythonExpr", line 1, in <expression>
AttributeError: 'FilesystemResourceDirectory' object has no attribute 'Language'

这是因为我的manifest.cfg中有以下行(与plone_control_panel中的参数行大致相同:

lang = python: context.Language()

在我的情况下,这是一种逻辑,因为并非所有内容对象都有一个名为Language()的索引。

但是这种情况下的'上下文'显然是指'FileSystemResourceDirectory',而不是你所在的内容? 如果我能找到更多信息,我会尝试使用pdb ...