为什么 getSite() 返回 FormlibValidation 对象
我已经在空白的 Plone 4.1 站点上安装了 Collective.quickupload, 并注意到当您添加一个quickupload portlet时,kss调用字段验证(plone.app.form.kss),getSite函数将返回一个FormlibValidation对象,这会导致quickupload词汇表崩溃。
回溯在这里:http://pastebin.com/nvwChpZd
我的问题是:
那是(getSite函数返回 FormlibValidation 对象)是错误还是预期行为?
修复/解决/使collective.quickupload工作的解决方案?
I've installed collective.quickupload on a blank Plone 4.1 site,
and noticed that when you add a quickupload portlet, kss calls for field validation (plone.app.form.kss), getSite function will return a FormlibValidation object, which cause the quickupload vocabularies crash.
The traceback is here: http://pastebin.com/nvwChpZd
My question is:
Is that (getSite function returns a FormlibValidation object) a bug or intended behaviour ?
Solution to fix/work around/make collective.quickupload work ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
getSite() 返回最近的组件站点(可以存储本地实用程序的位置),这实际上只意味着最后使用 setSite() 设置的内容,这通常发生在遍历时。
大多数时候,调用 setSite() 的唯一遍历钩子是当您遍历 Plone 站点时触发的钩子。但我认为旧的 KSS 内联表单验证机制使用(使用?)一种 hack,可以动态创建本地组件站点(在视图中),并在请求的其余部分将其设置为本地站点,以便它可以覆盖某些事物。
您可以禁用验证(例如禁用portal_kss中的相关KSS文件)或修复c.quickupload以检查getSite()的结果是否是ISiteRoot。如果不是,则应该对其进行获取包装,因此您可以执行 aq_parent(site) (或者可能是 site.parent)来循环获取父级,直到找到 ISiteRoot。
getSite() returns the nearest component site (where local utilities can be stored), which really just means whatever was last set with setSite(), which usually happens on traversal.
Most of the time, the only traversal hook that calls setSite() is the one that's triggered when you traverse over the Plone site. But I think the old KSS inline form validation machinery used (uses?) a hack that creates a local component site on the fly (in a view) and sets that as the local site during the remainder of the request so that it can override certain things.
You can disable validation (e.g. disable the relevant KSS file in portal_kss) or fix c.quickupload to check whether the result of getSite() is an ISiteRoot. If it isn't, it should be acquisition-wrapped, so you can do aq_parent(site) (or maybe site.parent) to get the parent in a loop until you find an ISiteRoot.