API for setting/getting values on Dexterity content
Andreas Jung <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi there, the following suggestion is based on former blog posts of mine, e.g. https://www.andreas-jung.com/contents/bad-dexterity-application-design https://www.andreas-jung.com/contents/copying-dexterity-fields-from-one-instance-to-another-instance I clearly see a need for an API for safely setting and getting values for Dexerity content that takes all aspects of behaviors into account. In general: direct attribute access to on Dexterity instance was a nice goal but in reality it is a broken and dangerous programming pattern in Plone right now - unless the direct getting/setting of values through direct attribute access can be fixed somehow (I think this is very hard). The safest way would be to provide methods like plone.api.content.set_value(obj, fieldname, value) value = plone.api.content.get_value(obj, fieldname) as part of plone.api or through methods of the Dexterity base classes Item and Container: obj.set_value(fieldname, value) value = obj.get_value(fieldname). The method names are dust and smoke and could be named differently. Any thoughts on the need for encapsulating the setting/getting of value? Any thoughts where such an API would fit best (plone.api vs. base classes)? -aj ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho