-
Notifications
You must be signed in to change notification settings - Fork 5
Manually modify a property of a plone object
Lukas Graf edited this page Dec 3, 2013
·
2 revisions
First start the instance in debug mode to get a Python prompt.
bin/instance0 debug
Then use debug helpers provided by opengever.maintenance
to get access to the Plone site.
>>> from opengever.maintenance.debughelpers import dm
>>> dm()
INFO: Using Plone Site 'plone'.
>>> plone
<PloneSite at /plone>
Get the a Plone object by traversing to it using restrictedTraverse
:
>>> dossier = plone.restrictedTraverse('folder/dossier')
>>> dossier
<DossierContainer at /plone/folder/dossier>
We need the annotation storage. This is where attributes of most schemata or behaviors are stored.
>>> from opengever.dossier.behaviors.dossier import IDossier
>>> attr_storage = IDossier(dossier)
>>> attr_storage
<plone.behavior.annotation.AnnotationsFactoryImpl object at 0xb4cb1cc>
Now modify the attribute.
>>> attr_storage.end
datetime.date(200, 7, 5)
>>> import datetime
>>> attr_storage.end = datetime.date(2003, 7, 5)
>>> attr_storage.end
datetime.date(2003, 7, 5)
And write your change to the database.
>>> import transaction
>>> transaction.commit()