Re: Computed fields in Dexterity?

dieter <[email protected]>
Newsgroups gmane.comp.web.zope.plone.user
Message-ID <[email protected]>
Sean Upton <[email protected]> writes:

> Is there any facility to do computed fields (similar to Archetypes) in
> zope.schema fields and z3c.form?
>
> I want to apply some kind of function (sum, average, etc) callable across
> other fields' respective values on the same form/context -- e.g. computed
> field_d = SUM(field_a, field_b, field_c).
>
> My only current constraint is that it be plone.supermodel-friendly
> (possible to serialize; maybe something syntactically similar to the way
> spreadsheets handle expressions).
>
> My sense is that there is not anything yet out there to do this?

You might be able to do something like this in the "invariant" part
of a "zope.interface.Interface". Its primary purpose is to verify
global interface conditions (relations among all fields in your case),
but I assume that you can also adjust such conditions (e.g. compute
field variables).

Note that your computed fields are not first class fields.
At the least, they must be "read_only". You might therefore
decide not to model them as fields at all but as properties
or "ComputedAttribute"s.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
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.