Adding tuple to subjects property of an object with Plone API (during create)

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?

By the way, on the create statement, the type='Document'. Sorry for the typo...

To change the state of an object you need to use:

obj = api.content.create(...)
api.content.transition(obj=obj, transition='publish')

Effective date should be a DateTime if I am not wrong otherwise I think objects are not visible by anonymous users

from DateTime import DateTime
DateTime(datetime.datetime.now())

For subjects it's indeed a tuple try adding it with a comma at the end

subjects = ('First Topic',  'Second Topic',)

EDIT: they keyword for subjects is subject

This in nonsense. You only need the comma trick for tuples with one item, not for #items > 1.

-aj

Thanks for the clarification

That's odd, because when you look at Dexterity editor (for creating content types), it is subjects plural, not singular. That's where I got the impression that it was plural in the first place. Typo?

The field in fact its called subjects, but stored on context.subject. Check this discussion: https://github.com/plone/plone.app.dexterity/issues/118