I'm trying to affect two properties of a Page object created via Plone API. Here is the code...
> from plone import api
> import transaction
> from plone.app.textfield.value import RichTextValue
> import datetime
>
> # You have to put the rich text content into a RichTextValue object and upload that object...
> S = RichTextValue(u'<p align="center">First Document</p><p align="center">Some Text</p>', 'text/html', 'text/x-html-safe')
> # The effective date is a datetime (object)...
> effective_date = datetime.datetime.now()
> # Subjects are a tuple (or at least that's what Dexterity suggested)...
> subjects = ('First Topic', 'Second Topic');
> # Be sure to get the portal...
> portal = api.portal.get()
>
> # Now, create the object...
> obj = api.content.create(type='opinion', title=u'A First Document', text=S, allow_discussion=True, effective_date=effective_date, subjects=subjects, state='published', container=portal)
Note, the only two things that don't get set properly are "state" and "subjects". The interesting thing is that allow_discussion gets set correctly. I can imaging that the "state" property isn't an actual property, and has to get set elsewhere as a transition. I can imaging that's the case, but in my situation, that isn't particularly desirable. I'm going to add tens of thousands of objects, and changing all their states would be a tedious chore, although one that probably could be automated. Still, it would be nice simply to set the state property when I create the object.
No, the really curious one is the subjects property. Theoretically, I should be able to add a tuple to that property and it should show up. Problem is, it doesn't. It is as though some properties aren't available for setting, but others are. Is there some rhyme or reason that I'm missing?