Re: API for setting/getting values on Dexterity content
Andreas Jung <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.devel |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thomas Massmann wrote: > Hi Andreas, > > Andreas Jung wrote: >>> So setting/getting a schema value could be (based on Andreas' >>> suggestion): plone.api.content.set_value(obj, fieldname, value, >>> behavior='behavior_name') value = >>> plone.api.content.get_value(obj, fieldname, >>> behavior='behavior_name') Same for Dexterity base classes: >>> obj.set_value(fieldname, value, behavior='behavior_name') value = >>> obj.get_value(fieldname, behavior='behavior_name') >> >> >> Why do you want the behavior name as explicit part of the API? My >> position is that this should be handled under the hood. > > How do you want to handle conflicts? I can think of a direct access > for default behaviors (this can be handled by the api) and an > indirect access for 3rd party behaviors. Just an idea ;) ok, I see and take your point. The 'behavior' parameter should be optional and used only if you have two or more behaviors introducing the same field name. An exception should be raised if you are trying to set a value in such a conflict case without explicit naming of the behavior. Likely most behaviors would use distinct field names...so a conflict would be a rare case. Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQGUBAEBAgAGBQJUR6CmAAoJEADcfz7u4AZjSwALv3/TDz7+JG+kPCmiAyhluQMf rIS7LgOzjU+SeqHy3f1XyCuLrQfL6kv/MZSFN3uRFmXZWy2NDRXgTXiJ5pkiGbwA uvcbkwOt7KTJk3CcA/b4937ZBgiZsuJ+gkGTpDGTORaWgIrfRA8Yo5jO2cL6O/3V u8ynUwWLeVcyEWYLHPTsxn95RFNfG6iSP2/UpsNizPONFeMyQFvOqCG1U5/PPEjY bBLrUYjn511nHrwagDHKUnm65XOyJjQPNmb8YDFrg1MbVEF06NFyaznJY0BR+kaG +G++XjQEvxtUr1lW+BHXEX+54QaMSHRLgks03jzluBjMgaNFDeDWbviJUAqEESW4 R/Xr8cA9e4P/AdMeYf/eFpd9PJWcg3cz+rVXmBfTu4M10jqnyj220uLvA2ImEaOH U19ojBORQC0U9my3wZOTkuguzyt5xmO2QqLqjOKp9MN3HhwKX+xzyeqFoEtejPwE XCeaYvbCFBuJx4G6ZEiZImglCsJmAGw= =dkrk -----END PGP SIGNATURE----- ------------------------------------------------------------------------------ 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