我正在使用带有 python 脚本的 Plone 5 来更改目录。在此过程中,我收到了 CSRF 保护错误。在 Plone 文档中,我找到了以下解决方案:
authenticator = context.restrictedTraverse("@@authenticator")
url = url + "?_authenticator=" + authenticator.token()
state.set(..., next_action='redirect_to:string:%s' % url)
执行此代码会导致:
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 344, in _exec
Module script, line 19, in my_script
- <PythonScript at /path/to/my_script used for /path/library>
- Line 19
Module plone.protect.authenticator, line 104, in token
Module plone.protect.authenticator, line 95, in createToken
Module plone.protect.authenticator, line 51, in _getKeyring
Module zope.component._api, line 169, in getUtility
ComponentLookupError: (<InterfaceClass plone.keyring.interfaces.IKeyManager>, '')
什么地方出了错?