First of all: I am running a Plonce Plone 4.3 (4305) instance with Dexterity Content Types 2.0.7
My approach is to write a Python Script (added via ZMI) which creates my dexterity content type using the methods invokeFactory(...)
or typestool.constructContent(..)
described here: http://plone.org/documentation/kb/add-content-programmatically (I've written two scripts which do the same task but use different methods - for learning purposes)
Everything is working fine, except when i try to add a DateTime Object to the constructor of both methods above to create my Content Type. The Date field strangly only updates the day and year values. Because of the restrictions in importing libraries inside python i am stuck (with my current knowledge) with this code:
d = DateTime('12/12/2013')
My script returns the date object after completion which looks like this:
2013/12/12 00:00:00 GMT+1
I've written another small script which outputs the Date value after construction and it gives me the same result (which seems to be correct). The resulting Content Type has its day and year field updated correctly but the month value stays on January and raises the following TypeError upon viewing:
TypeError: int() argument must be a string or a number, not 'instancemethod'
I can fix this by editing the month value manually which is not exactly what i want. I guess it its a minor problem with my DateTime object but i am running out of ideas at this point (overall documentation seems to be a bit scattered). I've tried various date formats inside the DateTime constructor but without luck.
I am also not sure how to modifiy my objects custom field values. Plone seems only to provide setTitle()
and setDescription()
methods. Maybe someone has a good hint.
Thanky you all in advance, regards
AFAIK, the problem is that DateTime field for dexterity types needs a datetime object, not a DateTime object.
In the invokeFactory, you should pass a datetime object instead of a DateTime object