Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ask the state for a content object?

Tags:

plone

At the end of this tutorial several object attributes are listed. But I need access to the state (published, private,...). I also search that attribute using dir() but I don't see an attribute named as state or something similar. i.e, I need something like this:

>>> app.Plone.foo.bar.state
"published"
like image 763
Daniel Hernández Avatar asked Dec 04 '22 00:12

Daniel Hernández


2 Answers

Or to keep your code more readable and not having to remember strange method names, you can use plone.api to do this:

from plone import api
api.content.get_state(obj=your_object)

Of course, you need to add plone.api to your eggs first, and re-run buildout.

like image 63
zupo Avatar answered Dec 26 '22 14:12

zupo


You can always use the plone_workflow to determine current status:

workflowTool = getToolByName(self.portal, "portal_workflow")
status = workflowTool.getStatusOf("plone_workflow", object)
# where "object" is your content object
print (status)
like image 44
user918176 Avatar answered Dec 26 '22 12:12

user918176