user1777144
user1777144

Reputation:

Plone : getting content of an object in python

I am currently trying to develop an egg for Plone to publish the content of an article onto facebook. I currently can get the title but I can't find a way to access to either the summary of the article or the body of it. I looked up the Dublin Core tags but it doesn't seem to be the proper way.

Does anyone know how to get this and store it in a variable ?

Thanks in advance.

Upvotes: 2

Views: 765

Answers (2)

user1777144
user1777144

Reputation:

Sorry for the long with no answer, so firstly thank you for your help. I managed to find out what I needed with what you told me.

When you decide to write a News item you have to write a title, a summary and a body.

The first thing to do is to get your object with the uuid and then with the following methods it is possible to get the content of each object :

context = uuidToObject(uuid)
title = context.Title()
summary = context.Description()
body = context.getText()

For the body you get a html text so it's up to you to do whatever you want with it.

Upvotes: 0

sdupton
sdupton

Reputation: 1879

Your content objects should have a CookedBody() method to render the body text for programmatic use in Python or in page templates (e.g. <div tal:content="structure context/CookedBody" />).

CookedBody() is a method defined in the interfaces of Products.CMFDefault, and was subsequently used by Plone for as far back as I can remember. ATContentTypes implements this for stock Plone types like Page/Document and News Item; I am not sure if Dexterity types do out-of-the-box (you might need to implement this method on your own custom content types, should that be a requirement).

Upvotes: 3

Related Questions