[Framework-Team] Re: PLIP 10359 for Plone 4.1 - Convert control panels to use z3c.form

David Glick davidglick at groundwire.org
Sun Mar 21 19:28:40 UTC 2010


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.

David

--
David Glick
Web Developer
Groundwire
206.286.1235x32
davidglick at groundwire.org
http://groundwire.org

ONE/Northwest is now Groundwire!




More information about the Framework-Team mailing list