[Framework-Team] Re: PLIP 10359 for Plone 4.1 - Convert control panels to use z3c.form
optilude+lists at gmail.com
Mon Mar 22 00:32:12 UTC 2010
David Glick wrote:
> On 3/21/10 12:21 PM, Hanno Schlichting wrote:
>> Is that a -1 on Martin's dict context / getContent() suggestion?
>> I'd like to have those forms be good examples of using z3c.form, so
>> I'd like to use whatever is considered to be best practice. The
>> use-case is having standalone forms which pull their data from a
>> different place.
> Most z3c.forms I've seen use a pattern similar to formlib forms, where
> the form context is adapted to the interface a field came from, and then
> values are retrieved/set via attribute access.
> I've also done something akin to Martin's suggestion, where getContent()
> is responsible for retrieving all the values from the context (and then
> memoizing the result), and a custom form action takes care of writing
> the values back to the appropriate locations.
> The first way probably results in less code in cases where the context
> already provides the interface you're using for the form. The second
> way probably results in less code in other cases. The first way is
> easier to override, since the reading/writing is factored out to a
> separate component from the form. The second way is probably a bit
> easier for newbies to figure out what's going on.
> So I guess it's not clear to me that there is one best practice, or at
> least not one that is best in all circumstances.
To me at least, the idea that we pick an arbitrary context (the Plone
site root) and then write a one-off adapter from that to some schema
interface that happens to represent the fields we want (the schema is
almost always form-specific, since we want to control fields, ordering,
fieldset grouping etc), register it in the CA (even though it's going to
be used only for the form) and then let the form framework look it up on
a field-by-field basis seems entirely like CA abuse. It's also quite
difficult to understand if you're reading the code.
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Framework-Team