Re: API for setting/getting values on Dexterity content

Johannes Raggam <[email protected]>
Newsgroups gmane.comp.web.zope.plone.devel
Message-ID <[email protected]>
On Thu, 2014-10-23 at 01:57 +0200, Johannes Raggam wrote:
> On Wed, 2014-10-22 at 23:50 +0200, Jens W. Klein wrote:
> > On 2014-10-22 14:07, Andreas Jung wrote:
> > >
> > >
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA1
> > >
> > >
> > >>
> > >> 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.
> > 
> > Well, its easy to iterate over main schema and behaviors to get the 
> > field name, i really dont get why everyone want to have the behavior 
> > name in the api. Maybe its not the fastest way to get the value, but if 
> > someone care about speed he/she can do the direct access way for the 
> > specific case anyway.
> 
> something like this code snippet in here:
> https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/utils.py#L134
> 
> again, this doesn't solve conflicting field names from different
> behaviors.

i recall, same field names in multiple behaviors work only, if behavior
adapters use plone.behavior.AnnotationStorage factory and are not stored
directly on the object (attribute storage). which makes
AnnotationStorage the preferred storage for behaviors from addons.


> 
> 
> > Jens
> > 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Plone-developers mailing list
> Plone-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/plone-developers

-- 
programmatic  web development
di(fh) johannes raggam / thet
python plone zope development
plone framework  team  member
mail: office-//[email protected]
web:  http://programmatic.pro
      http://bluedynamics.com

------------------------------------------------------------------------------

_______________________________________________
Plone-developers mailing list
Plone-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/plone-developers
signature.asc (application/pgp-signature, 181 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEABECAAYFAlRIRskACgkQW4mNMQxDgAc1pwCg4JPDcMpo/TrXro3WqfEHRt0E
UaMAnRFaKn+mLGi637a5/rCkPdM5N8o/
=faqN
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.