尝试在 plone 中显示对象状态会出现“没有工作流程提供‘${name}’”信息。”错误
我尝试使用以下代码返回对象状态:
workflow = getToolByName(context,'portal_workflow')
status = workflow.getInfoFor(obj,'review_state')
当我尝试使用以下代码输出时:
print "State: %s" % (status)
我收到以下错误:
异常类型工作流程
异常异常值没有工作流提供“${name}”信息。
我在网上阅读了一些内容,但似乎没有给出明确的答案。
有人可以帮忙吗?
编辑 这并不是因为对象没有工作流程。我试图获取状态的对象正在使用自定义工作流程。然而,将其切换为使用默认的克隆工作流程仍然会出现相同的错误。
已修复 在尝试了最简单的事情之后:
status = obj.review_state
这有效!想想吧。不管怎样,谢谢。
如果版主愿意,您可以删除此帖子。
I'm trying to return an objects state using the following code:
workflow = getToolByName(context,'portal_workflow')
status = workflow.getInfoFor(obj,'review_state')
When I try to output this using:
print "State: %s" % (status)
I get the following error:
Exception Type Workflow
Exception Exception Value No workflow provides '${name}' information.
I've done a little reading around the web but nothing seems to give a definitive answer.
Can anyone help?
EDIT
This is not down to an object not having workflow. The object im trying to get the state for is using custom workflow. However switching this to using the default plone workflow still troughs the same error.
FIXED
After just trying the simplest thing out:
status = obj.review_state
This works! go figure. Thanks anyway.
Moderators you can delete this post if you wish.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实上,贾科莫的回答是正确的。您尝试传递给
getInfoFor
方法的obj
是目录大脑,而不是实际的内容对象。这就是为什么要求它的review_state
直接对你有用。Plone 内容对象不知道它自己的工作流程状态。该信息由工作流程工具维护,这就是为什么当您查看实际内容对象时必须使用
workflow_tool.getInfoFor
在您的例子中,您已经获取了目录搜索的结果,该结果是一个称为“大脑”的轻量级结构,并尝试将其传递给工作流工具。目录大脑没有工作流程,因此您得到的错误是完全准确的。但目录大脑确实有一个
review_state
属性,它对应于目录大脑所表示的对象的审阅状态。简而言之,如果您有一个目录大脑,请使用
brain.review_state
,如果您有一个内容对象,请使用workflow_tool.getInfoFor(obj, 'review_state')
Actually, Giacomo's answer is correct. The
obj
you were trying to pass to thegetInfoFor
method is a catalog brain, not an actual content object. That is why asking for it'sreview_state
directly worked for you.A Plone content object has no knowledge of it's own workflow state. That information is maintained by the workflow tool, which is why when you are looking at an actual content object you must use
workflow_tool.getInfoFor
In your case, you've taken the result of a catalog search, which is a lightweight structure called a
brain
, and tried to pass it to the workflow tool. Catalog brains do not have workflow, so the error you got is perfectly accurate. But a catalog brain does have areview_state
attribute, which corresponds to the review state of the object represented by the catalog brain.In short, if you have a catalog brain, use
brain.review_state
, if you have a content object, useworkflow_tool.getInfoFor(obj, 'review_state')
这是因为您正在尝试获取没有任何关联工作流程的对象(可能是文件或图像)的工作流程状态。您可以在 zmi->portal_workflows 中检查所有内容类型-工作流程配对。
That's because you are trying to get the workflow state of an object that doesn't have any associated workflow (probably a File or an Image). You can check in zmi->portal_workflows all of the contenttype-workflows pairings.
在定义的变量选项卡(ZMI for Portal_workflow)中,在该页面的底部,确保状态变量名称为“review_state”——这可能不是默认值,IIRC。这可能是您的问题的可能根源之一。
In the variables tab of your definition (ZMI for portal_workflow), at the bottom of that page, make sure that state variable name is 'review_state' -- this may not be the default, IIRC. This may be one possible source of your problem.